mps-console
Skill1.7k starsChanged 2 months agoApache-2.0View on GitHub
Run or generate MPS Console code and `jetbrains.mps.lang.smodel.query` queries in MPS intentions, behavior, actions, generators, and BaseLanguage. Covers console commands, result printers, IDE operations, scripts, scoped node/model/module queries, and inserting, reading, recalling, or running commands through MPS MCP tools.
Trending
Quiet since October.thin dataabout the whole repository
Who's talking about JetBrains/MPS
- mbeddr/mps-gradle-plugin“Null pointer exception on generate”GitHub · May 18, 2020 · 1 reactions
- nebojsa-vuksic/skill-atlas“Scan every repository of an organization or user”GitHub · Oct 1, 2026
- modelix/modelix.editor“Implement MPS shortcuts”GitHub · Feb 21, 2023
The biggest 3 of 3 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository83 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- actionsSkill
- bugfix-workflowSkill
- code-styleSkill
- commitsSkill
- debuggingSkill
- mps-aspect-accessoriesSkill
- mps-aspect-actionsSkill
- mps-aspect-behaviorSkill
- mps-aspect-constraintsSkill
- mps-aspect-dataflowSkill
- mps-aspect-editor-menus-and-keymapsSkill
- mps-aspect-editorSkill
- mps-aspect-generation-planSkill
- mps-aspect-generatorSkill
- mps-aspect-intentionsSkill
- mps-aspect-migrationsSkill
- mps-aspect-structure-conceptsSkill
- mps-aspect-textgenSkill
- mps-aspect-typesystemSkill
- mps-baselanguageSkill
- mps-build-languageSkill
- mps-distribution-buildSkill
- mps-dsl-memorySkill
- mps-ide-pluginSkill
- mps-lang-core-xmlSkill
- mps-language-analysisSkill
- mps-language-aspects-overviewSkill
- mps-language-inheritanceSkill
- mps-language-modularitySkill
- mps-mcp-workflowSkill
- mps-model-manipulationSkill
- mps-node-editingSkill
- mps-project-managementSkill
- mps-quotationsSkill
- mps-run-configurationsSkill
- mps-testsSkill
- registrySkill
- skill-optimization-studySkill
- ssrSkill
- teamcity-cliSkill
- actionsSkill
- bugfix-workflowSkill
- code-styleSkill
- commitsSkill
- debuggingSkill
- mps-aspect-accessoriesSkill
- mps-aspect-actionsSkill
- mps-aspect-behaviorSkill
- mps-aspect-constraintsSkill
- mps-aspect-dataflowSkill
- mps-aspect-editor-menus-and-keymapsSkill
- mps-aspect-editorSkill
- mps-aspect-generation-planSkill
- mps-aspect-generatorSkill
- mps-aspect-intentionsSkill
- mps-aspect-migrationsSkill
- mps-aspect-structure-conceptsSkill
- mps-aspect-textgenSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 70
scopeparameter ≠withscope: When you pass scope explicitly as a query parameter it is used *as-is and keeps read-only models*, so … - Very specific: line 75
Never hand-edit the console's
.mpsmodel: Use the editor or the MCP tool.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MPS Console and the smodel query language
Loading companion skills
Companion names in this skill are lazy dependencies: load only those relevant to the current task. If this skill came from an MCP server, use the host's skill loader to resolve the companion's unique discovered entry URI on the same host-assigned originating server. If the host has no server-backed skill loader, stop and report that limitation; do not silently fall back to a filesystem copy. If this skill came from a filesystem catalog, load the named sibling from that same catalog at <skills-root>/<skill-name>/SKILL.md, even if remote skill loaders are also available. Do not invent a tool name or server endpoint.
The MPS Console runs DSL code against the live models of the open project: query and mutate nodes, run find-usages, gather statistics, make/clean models, reload classes. Code is typed line-by-line, generated by the MPS generator, and executed in the IDE context. Most console-specific constructs start with # and completion (Ctrl+Space) inserts them.
The smodel query language (jetbrains.mps.lang.smodel.query) exposes the same queries (#nodes, #instances, #usages, …) for use in ordinary model code — intentions, behavior methods, actions, migration/refactoring scripts — wrapped in a with (<scope>) { … } statement. Reach for it whenever code needs to enumerate nodes/models/modules or find instances/usages across a scope.
Ways this skill gets used
- Type code in the Console tool window (Tools ▸ Console, or the Console tool window). One command per input. See
references/console-languages.md. - Write
smodel.queryqueries inside model code (an intention, behavior method, generator query, script). Importjetbrains.mps.lang.smodel.queryand wrap queries inwith (<scope>) { … }. Seereferences/smodel-query.md. - Insert code into the Console from an agent via
mps_mcp_insert_console_command_from_json— builds a command from a JSON blueprint and drops it into the console input without executing it (the user reviews and runs it with Ctrl+Enter). Seereferences/mcp-insertion.md, which also has a generator script for a query with.where(…)/.select(…)closures. - Read the current Console command from an agent via
mps_mcp_get_current_editor_root_nodewithsource = "console"— returns the node-info envelope of the command currently in the console input (one an agent inserted, or the user typed). Feed itsreferencetomps_mcp_print_nodefor the JSON blueprint (format = "JSON") or the notational printout (format = "PLAIN TEXT"/"HTML"), or tomps_mcp_check_root_node_problemsto see the problems MPS's model checker reports for it (way #8). The reference is only valid until the next console interaction (execute / clear / history navigation), so print it promptly and do not cache it. - Browse the Console history from an agent via
mps_mcp_get_console_history— lists previously executed commands in order, each with a one-linepreview, a history-entryreference, and aneffectiveCommandReference. Pass the entryreferenceto recall; passeffectiveCommandReferencetomps_mcp_print_node. UseincludeResponses = trueto also list each command's printed output as akind:responseentry right after it, with a one-linepreview; see "Reading a command's output" below for the full text and for the node references inside it. Same reference-validity caveat as #4. - Recall a history command into the input via
mps_mcp_recall_console_command(historyNodeReference)— deep-copies a history entry (from #5) back into the input slot without executing it. Pass the history entry'sreference, not itseffectiveCommandReference. There is no MPS "recall" API to call directly; this mirrors what the Console's own up/down history navigation does (copy+ insert). - Run the current Console command from an agent via
mps_mcp_run_console_command— executes whatever command is currently in the input (placed there by #3 or #6, or typed by the user), exactly as Ctrl+Enter, and only when a command is present. It executes code with side effects. The response is not returned by the tool; read it afterwards as "Reading a command's output" below describes, and note that long-running commands (make/generate) complete asynchronously. - Check a Console command for problems from an agent via
mps_mcp_check_root_node_problems— pass thereferencefrom way #4 (or aneffectiveCommandReferencefrom way #5) and it runs MPS's full checker set (structure, constraints, reference scopes, typesystem, and checking rules), surfacing the same errors/warnings the Console editor underlines and the Model Checker reports. Two caveats: (a) root-scoped — the tool checks the command'scontainingRoot, which for console code is the singleConsoleRootholding the current input and the entire history, so results can include problems from earlier commands; with the defaultonlyNodesWithProblems = trueyou get a flat list of problem nodes, so match each one'srootName/subtree to the command you mean. (b) Same reference-validity window as #4 — resolve and check before the next console interaction.
A command is one of three shapes
The console input holds exactly one command (jetbrains.mps.console.base.structure.Command):
| Shape | Concept | What it is |
| BaseLanguage statements | BLCommand (alias {) — body: StatementList | a { … } block of imperative statements; the value of a trailing expression statement is printed |
| BaseLanguage expression | BLExpression — expression: Expression | one expression; if non-void its value is printed (as text / AST / interactive response) |
| Interpreted command | InterpretedCommand subtypes | non-generated commands: #stat, #showGenPlan, #showBrokenRefs, #reloadClasses, ? (help) |
Key fact that trips up blueprints: the query commands (#nodes, #instances, …), the IDE commands #make / #clean / #removeGenSources / #show / #callAction, and the printers #print / #printNode / #printNodeRef / #printSequence / #printText are all baseLanguage Expressions, not Commands. To use one as a standalone command you put it inside a BLExpression (or inside { … } statements). Only InterpretedCommand subtypes and #reloadClasses are commands in their own right.
Reading a command's output
mps_mcp_run_console_command does not return the output, and execution is asynchronous. To read it:
- Before running, note the
indexof the last history entry (limit = 1);indexcounts the whole history, so your command is thekind:commandwith a higherindex, even when it repeats an earlier command. After running, callmps_mcp_get_console_history(includeResponses = true, limit = 2). The command is finished when the last entry is akind:responseand the entry before it is yourkind:command. If yourkind:commandis the last entry, it is still running, or it printed nothing: a command that prints nothing gets no response entry. If your command is not listed yet, it has not started. Call again a few times, then stop waiting. - The response entry's
previewis the printed text with whitespace and line breaks collapsed to single spaces, cut at 200 characters. It is omitted when the text is empty or cannot be rendered, and for long responses (over 100 items, where each printed value and each line break counts). ReadpreviewCompletenext to it:true: the preview is the exact printed text, with only the Console's leading and trailing padding removed. This is the usual case for a count (3 nodes) or a short one-line value list. Report it as it is; do not print the node again.false(the preview was cut and ends in…, or it was collapsed from several lines), or nopreviewat all: callmps_mcp_print_node(nodeReference = <the response entry's reference>, format = "PLAIN TEXT")for the exact full text.
- For node references in the output, print the same
referencewithformat = "JSON"anddeep = true. Each printed node is anitemchild holding aNodeReferencePresentation. ThetargetReferenceof itstargetreference is the real node, which you can pass to any other tool.
The console prints a value according to its type, and an agent can only get back what was printed:
| Value | Printed text | Response node children (item) |
a non-empty sequence or list of nodes, references, models, or modules (#instances(C), .where(…), .toList, #models) | only a count, e.g. 3 nodes or 12 models. In the IDE the count links to the usages view. | one NodeResponseItem → NodeWithClosure, whose text is the count. The items cannot be recovered. |
| an empty sequence of any of these | empty sequence | one TextResponseItem |
a single node (.first, #print node) | the node's presentation, usually its name | NodeResponseItem → NodeReferencePresentation, target = the node |
| anything else: a string, a number, a sequence of strings | the value's toString(), e.g. [Flour, Sugar, Egg] | one TextResponseItem, whose text is that string |
So shape the query for what you need back:
- Values: select them before printing:
#instances(Ingredient).select({~it => it.name; })prints one list of the names, such as[Flour, Sugar, Egg]. - Node references: print each node:
#instances(Ingredient).forEach({~it => #print it; })gives oneNodeReferencePresentationper node, read with step 3. - Not
.forEach({~it => #print it.name; })for values. The items print separated only by spaces, so a name containing a space cannot be told apart from two names.
Critical Directives
- This skill is the controlling workflow for Console tasks. Start from surface syntax first — choose the query (
#instances,#usages,#nodes, …), filter and transform withsmodel/collections/closures, then insert or run via the console MCP tools. Only fall back to low-level Java/MPS-OpenAPI approaches if the surface syntax route has genuinely failed. - Pick the scope deliberately. Without a scope, console queries run over all editable models of the current project; a
withstatement defaults to editable models too, so model-changing code is safe. Scopes:project,editable,global,visible,modules(...),models(...),custom(<SearchScope>). Seereferences/smodel-query.md. scopeparameter ≠withscope. When you passscopeexplicitly as a query parameter it is used as-is and keeps read-only models, so#nodesinsidewith(project)and#nodes<scope project>can return different results.- No nested
with. Awithstatement may not contain anotherwith. - Lazy vs eager:
#nodes/#references/#models/#modulesare lazy sequences (full iteration).#instances/#usagesuse the find-usages index — far faster than iterate-then-filter. Prefer#instances(C)over#nodes.ofConcept<C>(). exactparameter on#instancesexcludes instances of sub-concepts (#instances<exact>(C)).- MetaAdapterFactory is a rabbit-hole warning for Console tasks. If you feel tempted to use
MetaAdapterFactory, hex feature IDs, generatedStructureAspectDescriptorcode, or hand-builtSConcept/SContainmentLinkobjects while solving a Console command, stop and reframe the solution in surface syntax instead:#instances(Concept),node.property,node.childRole,replace with new(Concept),.forEach, or.refactor.MetaAdapterFactorybelongs to low-level/generated implementation details, not the first-line solution for MPS Console work. - Never hand-edit the console's
.mpsmodel. Use the editor or the MCP tool. The console lives in a temporaryConsoleModel_*model. - Insertion and recall do not execute.
mps_mcp_insert_console_command_from_jsonandmps_mcp_recall_console_commandonly place a command in the input; by default leave it for the user to run and tell them it is waiting. To execute it yourself, callmps_mcp_run_console_command(way #7) — it runs code with side effects, so do it deliberately and report what it did. - Bulk node mutation: pick
refactorvsforEachby whether you will run it..refactor({~it => … })(RefactorOperation) pops a modal confirmation dialog and applies nothing until a human approves it;.forEach({~it => … })(collectionsVisitAllOperation) applies its closure immediately, in the console's own write command, with no dialog. So: when the user asks only to create / insert a command for them to run themselves (mps_mcp_insert_console_command_from_jsonand stop), preferrefactor— the dialog gives them a review-and-confirm step at the keyboard. When the user asks you to create and run it yourself (you will callmps_mcp_run_console_command), preferforEach—refactorwould returnexecuted:truebut stall on the dialog with no human present, leaving the model unchanged and the run a silent no-op.
Examples (surface syntax)
#models // all editable models in the project
#modules<global> // every module in the repository
#instances(ClassConcept) // fast: all ClassConcept instances in scope
#instances<exact>(BaseConcept) // exclude sub-concepts
#usages(aNode) // direct references to a node
#print 2 + 2 // smart-print a value
#printNode someNode // print a node copy
#show #instances(Issue) // open the result in the usages view
#make #models<modules myModule> // make selected models
#reloadClasses // reload generated classes
// migrate every TryStatement with a catch + long body to TryCatchStatement (from the MPS docs)
// `.forEach` applies immediately and headlessly; `.refactor` instead pops a confirmation dialog
#instances(TryStatement).where({~it => it.catchClause.isNotEmpty; }).forEach({~node => if (node.body.statement.size > 5) { node.replace with new(TryCatchStatement); } })Related Skills
mps-model-manipulation— thesmodel/collections/closuresoperations (.where,.select,.ofConcept<C>,replace with new(C),:eq:) used in the bodies of console commands,withblocks, andrefactorclosures. The smodel query language layers on top of these.mps-node-editing— the JSON blueprint format thatmps_mcp_insert_console_command_from_jsonconsumes (shared withmps_mcp_insert_root_node_from_json).mps-aspect-intentions— a common host forwith (…) { #instances(…)… }queries.mps-baselanguage— host BaseLanguage statements/expressions that fillBLCommand/BLExpression.mps-run-configurations— for running amain/test root node instead of console code.
Reference Index
- Open
references/console-languages.mdfor the full console command-language reference — every#command grouped by language (base,ideCommands,internalCommands,scripts), aliases, what each prints, scopes, paste-as-nodeRef, and#execscripts. - Open
references/smodel-query.mdfor thejetbrains.mps.lang.smodel.querylanguage used in model code — thewithstatement, the six query expressions, scope parameters, thescope/exact/r/o+query parameters, default-scope rules, and intention/behavior usage examples. - Open
references/mcp-insertion.mdformps_mcp_insert_console_command_from_json— the two accepted JSON shapes, validated working blueprints (BLExpression+ query, statement arrays, interpreted commands), concept FQNs and language UUIDs, the "wrap expressions inBLExpression" gotcha, anddryRunvalidation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

