@rsconcept/rstool-mcp 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -21
- package/dist/bin/server.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{server-BuxSpa2B.js → server-DhX7UEC1.js} +36 -1
- package/dist/{server-BuxSpa2B.js.map → server-DhX7UEC1.js.map} +1 -1
- package/package.json +1 -1
- package/src/server.test.ts +1 -0
- package/src/tools.ts +39 -0
package/README.md
CHANGED
|
@@ -72,27 +72,28 @@ Edit `claude_desktop_config.json` (`~/Library/Application Support/Claude/` on ma
|
|
|
72
72
|
|
|
73
73
|
## Exposed tools
|
|
74
74
|
|
|
75
|
-
| MCP tool | Wraps | Notes
|
|
76
|
-
| --------------------- | ------------------- |
|
|
77
|
-
| `ping` | — | Liveness + `contractVersion`.
|
|
78
|
-
| `list_methods` | — | Enumerate available tools.
|
|
79
|
-
| `ensure_session` | `ensureSession` | Return active session or create one.
|
|
80
|
-
| `create_session` | `createSession` | Optional `initial` seed.
|
|
81
|
-
| `set_current_session` | `setCurrentSession` | Switch active session.
|
|
82
|
-
| `get_current_session` | `getCurrentSession` | Current session handle, or `null`.
|
|
83
|
-
| `apply_schema_patch` | `applySchemaPatch` | Primary schema edit path.
|
|
84
|
-
| `get_session_state` | `getSessionState` | `detail=summary` (default) or `full`.
|
|
85
|
-
| `analyze_expression` | `analyzeExpression` | Scratch analysis.
|
|
86
|
-
| `list_diagnostics` | `listDiagnostics` | Optional `constituentId`.
|
|
87
|
-
| `commit_step` | `commitStep` | Records a revision.
|
|
88
|
-
| `export_session` | `exportSession` | JSON string.
|
|
89
|
-
| `export_portal` | `exportPortal` | `kind=schema\|model`, `format=json\|object`.
|
|
90
|
-
| `import_data` | `importData` | `kind=auto` by default.
|
|
91
|
-
| `set_model_values` | `setModelValues` | `set[]` and/or `clear[]`.
|
|
92
|
-
| `get_model_state` | `getModelState` | Values + statuses.
|
|
93
|
-
| `evaluate` | `evaluate` | Scratch or stored constituent.
|
|
94
|
-
| `recalculate_model` | `recalculateModel` | Full recompute.
|
|
95
|
-
| `restore_order` | `restoreOrder` | Restore declaration order (topo + semantic).
|
|
75
|
+
| MCP tool | Wraps | Notes |
|
|
76
|
+
| --------------------- | ------------------- | --------------------------------------------- |
|
|
77
|
+
| `ping` | — | Liveness + `contractVersion`. |
|
|
78
|
+
| `list_methods` | — | Enumerate available tools. |
|
|
79
|
+
| `ensure_session` | `ensureSession` | Return active session or create one. |
|
|
80
|
+
| `create_session` | `createSession` | Optional `initial` seed. |
|
|
81
|
+
| `set_current_session` | `setCurrentSession` | Switch active session. |
|
|
82
|
+
| `get_current_session` | `getCurrentSession` | Current session handle, or `null`. |
|
|
83
|
+
| `apply_schema_patch` | `applySchemaPatch` | Primary schema edit path. |
|
|
84
|
+
| `get_session_state` | `getSessionState` | `detail=summary` (default) or `full`. |
|
|
85
|
+
| `analyze_expression` | `analyzeExpression` | Scratch analysis. |
|
|
86
|
+
| `list_diagnostics` | `listDiagnostics` | Optional `constituentId`. |
|
|
87
|
+
| `commit_step` | `commitStep` | Records a revision. |
|
|
88
|
+
| `export_session` | `exportSession` | JSON string. |
|
|
89
|
+
| `export_portal` | `exportPortal` | `kind=schema\|model`, `format=json\|object`. |
|
|
90
|
+
| `import_data` | `importData` | `kind=auto` by default. |
|
|
91
|
+
| `set_model_values` | `setModelValues` | `set[]` and/or `clear[]`. |
|
|
92
|
+
| `get_model_state` | `getModelState` | Values + statuses. |
|
|
93
|
+
| `evaluate` | `evaluate` | Scratch or stored constituent. |
|
|
94
|
+
| `recalculate_model` | `recalculateModel` | Full recompute. |
|
|
95
|
+
| `restore_order` | `restoreOrder` | Restore declaration order (topo + semantic). |
|
|
96
|
+
| `synthesize` | `synthesize` | Embed another session + identification table. |
|
|
96
97
|
|
|
97
98
|
Session tools accept optional `sessionId` (flat params, no `input` wrapper). Prefer `apply_schema_patch` for schema edits.
|
|
98
99
|
|
package/dist/bin/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as buildRSToolMcpServer } from "../server-
|
|
2
|
+
import { t as buildRSToolMcpServer } from "../server-DhX7UEC1.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
//#region src/bin/server.ts
|
|
5
5
|
async function main() {
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TOOL_DEFINITIONS, t as buildRSToolMcpServer } from "./server-
|
|
1
|
+
import { n as TOOL_DEFINITIONS, t as buildRSToolMcpServer } from "./server-DhX7UEC1.js";
|
|
2
2
|
export { TOOL_DEFINITIONS, buildRSToolMcpServer };
|
|
@@ -325,6 +325,41 @@ const TOOL_DEFINITIONS = [
|
|
|
325
325
|
properties: { sessionId }
|
|
326
326
|
},
|
|
327
327
|
invoke: (tool, args) => tool.restoreOrder(optionalSessionId(args))
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: "synthesize",
|
|
331
|
+
description: "Synthesis by embedding: merge constituents from sourceSessionId into the receiver session, then apply an identification table (aliases).",
|
|
332
|
+
inputSchema: {
|
|
333
|
+
type: "object",
|
|
334
|
+
properties: {
|
|
335
|
+
sessionId,
|
|
336
|
+
sourceSessionId: {
|
|
337
|
+
type: "string",
|
|
338
|
+
description: "Session to merge from (must differ from the receiver)."
|
|
339
|
+
},
|
|
340
|
+
items: {
|
|
341
|
+
type: "array",
|
|
342
|
+
items: { type: "string" },
|
|
343
|
+
description: "Optional source aliases to import. Omit or empty = import all."
|
|
344
|
+
},
|
|
345
|
+
substitutions: {
|
|
346
|
+
type: "array",
|
|
347
|
+
items: {
|
|
348
|
+
type: "object",
|
|
349
|
+
properties: {
|
|
350
|
+
original: { type: "string" },
|
|
351
|
+
substitution: { type: "string" }
|
|
352
|
+
},
|
|
353
|
+
required: ["original", "substitution"]
|
|
354
|
+
},
|
|
355
|
+
description: "Identification table: each row pairs one source alias with one receiver alias."
|
|
356
|
+
},
|
|
357
|
+
commitMessage: { type: "string" }
|
|
358
|
+
},
|
|
359
|
+
required: ["sourceSessionId"],
|
|
360
|
+
additionalProperties: true
|
|
361
|
+
},
|
|
362
|
+
invoke: (tool, args) => tool.synthesize(omitSessionId(args), optionalSessionId(args))
|
|
328
363
|
}
|
|
329
364
|
];
|
|
330
365
|
//#endregion
|
|
@@ -389,4 +424,4 @@ function buildRSToolMcpServer(options = {}) {
|
|
|
389
424
|
//#endregion
|
|
390
425
|
export { TOOL_DEFINITIONS as n, buildRSToolMcpServer as t };
|
|
391
426
|
|
|
392
|
-
//# sourceMappingURL=server-
|
|
427
|
+
//# sourceMappingURL=server-DhX7UEC1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-BuxSpa2B.js","names":[],"sources":["../src/tools.ts","../src/server.ts"],"sourcesContent":["/**\n * MCP tool definitions for the @rsconcept/rstool contract.\n */\n\nimport { type RSToolAgent } from \"@rsconcept/rstool\";\n\nexport interface ToolDefinition {\n name: string;\n description: string;\n inputSchema: {\n type: \"object\";\n properties: Record<string, unknown>;\n required?: string[];\n additionalProperties?: boolean;\n };\n invoke: (\n tool: RSToolAgent,\n args: Record<string, unknown>,\n ) => unknown | Promise<unknown>;\n}\n\nconst sessionId = {\n type: \"string\",\n description: \"Session id. Omit to use the current active session.\",\n};\n\nconst agentPatchSchema = {\n type: \"object\",\n description:\n \"Agent-friendly constituent patch. id and cstType are optional; cstType is inferred from alias prefixes X/C/S/D/A/F/P.\",\n properties: {\n id: { type: \"number\" },\n alias: { type: \"string\" },\n cstType: { type: \"string\" },\n definitionFormal: { type: \"string\" },\n term: { type: \"string\" },\n definitionText: { type: \"string\" },\n convention: { type: \"string\" },\n },\n required: [\"alias\"],\n};\n\nfunction optionalSessionId(args: Record<string, unknown>): string | undefined {\n const value = args.sessionId;\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction omitSessionId(args: Record<string, unknown>): Record<string, unknown> {\n const { sessionId: _sessionId, ...rest } = args;\n return rest;\n}\n\nexport const TOOL_DEFINITIONS: ToolDefinition[] = [\n {\n name: \"ping\",\n description:\n \"Liveness check; returns {pong: true} and the active rstool contract version.\",\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n invoke: (tool) => ({ pong: true, contractVersion: tool.contractVersion }),\n },\n {\n name: \"list_methods\",\n description: \"List all rstool methods exposed as MCP tools.\",\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n invoke: () => TOOL_DEFINITIONS.map((definition) => definition.name),\n },\n {\n name: \"ensure_session\",\n description:\n \"Return the current active session, or create one if none exists. Optional initial seed is used only when creating.\",\n inputSchema: {\n type: \"object\",\n properties: {\n initial: {\n type: \"object\",\n properties: {\n alias: { type: \"string\" },\n title: { type: \"string\" },\n comment: { type: \"string\" },\n },\n additionalProperties: true,\n },\n },\n additionalProperties: false,\n },\n invoke: (tool, args) => tool.ensureSession(args.initial as never),\n },\n {\n name: \"create_session\",\n description:\n \"Create a fresh in-memory rstool session and set it as the current active session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n initial: {\n type: \"object\",\n description:\n \"Optional partial SessionState seed (alias, title, comment).\",\n properties: {\n alias: { type: \"string\" },\n title: { type: \"string\" },\n comment: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n additionalProperties: false,\n },\n invoke: (tool, args) => tool.createSession(args.initial as never),\n },\n {\n name: \"set_current_session\",\n description: \"Set the active session by id.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n required: [\"sessionId\"],\n },\n invoke: (tool, args) => tool.setCurrentSession(String(args.sessionId)),\n },\n {\n name: \"get_current_session\",\n description: \"Return the current active session, or null if none exists.\",\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n invoke: (tool) => tool.getCurrentSession(),\n },\n {\n name: \"apply_schema_patch\",\n description:\n \"Preferred schema edit path. Batch patch with inferred ids and cstType, dependency ordering, and compact summary.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n initial: {\n type: \"object\",\n properties: {\n alias: { type: \"string\" },\n title: { type: \"string\" },\n comment: { type: \"string\" },\n },\n additionalProperties: true,\n },\n items: { type: \"array\", items: agentPatchSchema },\n mode: { type: \"string\", enum: [\"atomic\", \"best_effort\"] },\n commitMessage: { type: \"string\" },\n },\n required: [\"items\"],\n },\n invoke: (tool, args) =>\n tool.applySchemaPatch(\n omitSessionId(args) as never,\n optionalSessionId(args),\n ),\n },\n {\n name: \"get_session_state\",\n description:\n \"Return session state. detail=summary (default): compact metadata, aliases, diagnostics. detail=full: complete SessionState clone.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n detail: { type: \"string\", enum: [\"summary\", \"full\"] },\n },\n },\n invoke: (tool, args) =>\n tool.getSessionState(\n (args.detail as \"summary\" | \"full\" | undefined) ?? \"summary\",\n optionalSessionId(args),\n ),\n },\n {\n name: \"analyze_expression\",\n description:\n \"Parse and type-check a scratch expression without saving it. Does not record diagnostics unless recordDiagnostics=true.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n expression: { type: \"string\" },\n cstType: { type: \"string\" },\n recordDiagnostics: { type: \"boolean\" },\n },\n required: [\"expression\", \"cstType\"],\n },\n invoke: (tool, args) =>\n tool.analyzeExpression(\n omitSessionId(args) as never,\n optionalSessionId(args),\n ),\n },\n {\n name: \"list_diagnostics\",\n description:\n \"List active diagnostics for the session: expression (formula), schema (homonyms, duplicates, metadata), model (interpretation status).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n constituentId: { type: \"number\" },\n kind: { type: \"string\", enum: [\"expression\", \"schema\", \"model\"] },\n },\n },\n invoke: (tool, args) => {\n const constituentId = args.constituentId;\n const kind = args.kind;\n const filters: {\n constituentId?: number;\n kind?: \"expression\" | \"schema\" | \"model\";\n } = {};\n if (typeof constituentId === \"number\") {\n filters.constituentId = constituentId;\n }\n if (kind === \"expression\" || kind === \"schema\" || kind === \"model\") {\n filters.kind = kind;\n }\n return tool.listDiagnostics(\n Object.keys(filters).length > 0 ? filters : undefined,\n optionalSessionId(args),\n );\n },\n },\n {\n name: \"commit_step\",\n description:\n \"Record a session revision with an optional human-readable message.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n message: { type: \"string\" },\n },\n },\n invoke: (tool, args) =>\n tool.commitStep(\n args.message as string | undefined,\n optionalSessionId(args),\n ),\n },\n {\n name: \"export_session\",\n description:\n \"Serialize the session to a JSON string suitable for import_data with kind=session.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.exportSession(optionalSessionId(args)),\n },\n {\n name: \"export_portal\",\n description:\n \"Export Portal Load-from-JSON payload. kind=schema|model; format=json (default string) or object.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n kind: { type: \"string\", enum: [\"schema\", \"model\"] },\n format: { type: \"string\", enum: [\"json\", \"object\"] },\n },\n required: [\"kind\"],\n },\n invoke: (tool, args) =>\n tool.exportPortal(omitSessionId(args) as never, optionalSessionId(args)),\n },\n {\n name: \"import_data\",\n description:\n \"Import a session from export_session JSON, Portal schema JSON, or GET /api/rsforms/:id/details. kind=auto (default) detects the shape.\",\n inputSchema: {\n type: \"object\",\n properties: {\n payload: {\n description:\n \"JSON string or parsed object (session export, Portal schema, or rsform details).\",\n },\n kind: {\n type: \"string\",\n enum: [\"auto\", \"session\", \"portal-schema\", \"portal-details\"],\n },\n },\n required: [\"payload\"],\n },\n invoke: (tool, args) =>\n tool.importData(args.payload as string | object, args.kind as never),\n },\n {\n name: \"set_model_values\",\n description:\n \"Set and/or clear interpretable model bindings. Pass set[] for bindings and clear[] for constituent ids to reset.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n set: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n target: { type: \"number\" },\n type: { type: \"string\" },\n value: {},\n },\n required: [\"target\", \"value\"],\n },\n },\n clear: { type: \"array\", items: { type: \"number\" } },\n },\n },\n invoke: (tool, args) =>\n tool.setModelValues(\n omitSessionId(args) as never,\n optionalSessionId(args),\n ),\n },\n {\n name: \"get_model_state\",\n description: \"Return the SessionModelState.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.getModelState(optionalSessionId(args)),\n },\n {\n name: \"evaluate\",\n description:\n \"Evaluate a scratch expression (expression + cstType) or a stored constituent (constituentId).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n expression: { type: \"string\" },\n cstType: { type: \"string\" },\n constituentId: { type: \"number\" },\n },\n },\n invoke: (tool, args) =>\n tool.evaluate(omitSessionId(args) as never, optionalSessionId(args)),\n },\n {\n name: \"recalculate_model\",\n description: \"Recompute every inferrable constituent.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.recalculateModel(optionalSessionId(args)),\n },\n {\n name: \"restore_order\",\n description:\n \"Restore constituent declaration order: formal topology, semantic clusters when ready, otherwise stable type/kernel ranks.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.restoreOrder(optionalSessionId(args)),\n },\n];\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\n\nimport { RSToolAgent } from \"@rsconcept/rstool\";\n\nimport { TOOL_DEFINITIONS, type ToolDefinition } from \"./tools\";\n\nexport interface BuildRSToolMcpServerOptions {\n /** Pre-built RSToolAgent. Defaults to a fresh in-memory instance. */\n tool?: RSToolAgent;\n /** Persist sessions to this directory (also reads RSTOOL_PERSISTENCE_DIR when set). */\n persistenceDir?: string;\n /** Server name advertised to MCP clients. */\n name?: string;\n /** Server version advertised to MCP clients. */\n version?: string;\n}\n\n/**\n * Build an MCP `McpServer` instance that exposes the `@rsconcept/rstool` contract.\n *\n * The returned server is not yet connected to a transport. Wrap it with a\n * `StdioServerTransport` (for local subprocess hosts like Cursor and Claude Desktop) or\n * an HTTP transport, then call `server.connect(transport)`.\n *\n * @example\n * ```ts\n * import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n * import { buildRSToolMcpServer } from '@rsconcept/rstool-mcp';\n *\n * const server = buildRSToolMcpServer();\n * await server.connect(new StdioServerTransport());\n * ```\n */\nexport function buildRSToolMcpServer(\n options: BuildRSToolMcpServerOptions = {},\n): McpServer {\n const persistenceDir =\n options.persistenceDir ?? process.env.RSTOOL_PERSISTENCE_DIR;\n const tool =\n options.tool ??\n new RSToolAgent(persistenceDir ? { persistenceDir } : undefined);\n const server = new McpServer(\n {\n name: options.name ?? \"rstool-mcp\",\n version: options.version ?? \"0.1.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n\n const definitionByName = new Map<string, ToolDefinition>(\n TOOL_DEFINITIONS.map((definition) => [definition.name, definition]),\n );\n\n server.server.setRequestHandler(ListToolsRequestSchema, () =>\n Promise.resolve({\n tools: TOOL_DEFINITIONS.map((definition) => ({\n name: definition.name,\n description: definition.description,\n inputSchema: definition.inputSchema,\n })),\n }),\n );\n\n server.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const definition = definitionByName.get(request.params.name);\n if (!definition) {\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `Unknown rstool tool: ${request.params.name}`,\n },\n ],\n };\n }\n\n try {\n const result = await definition.invoke(\n tool,\n request.params.arguments ?? {},\n );\n const text =\n typeof result === \"string\" ? result : JSON.stringify(result, null, 2);\n return {\n content: [\n {\n type: \"text\" as const,\n text,\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `rstool error in ${definition.name}: ${message}`,\n },\n ],\n };\n }\n });\n\n return server;\n}\n"],"mappings":";;;;AAqBA,MAAM,YAAY;CAChB,MAAM;CACN,aAAa;A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SAAS,CACP;KACE,MAAM;KACN,MAAM,mBAAmB,WAAW,KAAK,IAAI;IAC/C,CACF;GACF;EACF;CACF,CAAC;CAED,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"server-DhX7UEC1.js","names":[],"sources":["../src/tools.ts","../src/server.ts"],"sourcesContent":["/**\n * MCP tool definitions for the @rsconcept/rstool contract.\n */\n\nimport { type RSToolAgent } from \"@rsconcept/rstool\";\n\nexport interface ToolDefinition {\n name: string;\n description: string;\n inputSchema: {\n type: \"object\";\n properties: Record<string, unknown>;\n required?: string[];\n additionalProperties?: boolean;\n };\n invoke: (\n tool: RSToolAgent,\n args: Record<string, unknown>,\n ) => unknown | Promise<unknown>;\n}\n\nconst sessionId = {\n type: \"string\",\n description: \"Session id. Omit to use the current active session.\",\n};\n\nconst agentPatchSchema = {\n type: \"object\",\n description:\n \"Agent-friendly constituent patch. id and cstType are optional; cstType is inferred from alias prefixes X/C/S/D/A/F/P.\",\n properties: {\n id: { type: \"number\" },\n alias: { type: \"string\" },\n cstType: { type: \"string\" },\n definitionFormal: { type: \"string\" },\n term: { type: \"string\" },\n definitionText: { type: \"string\" },\n convention: { type: \"string\" },\n },\n required: [\"alias\"],\n};\n\nfunction optionalSessionId(args: Record<string, unknown>): string | undefined {\n const value = args.sessionId;\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction omitSessionId(args: Record<string, unknown>): Record<string, unknown> {\n const { sessionId: _sessionId, ...rest } = args;\n return rest;\n}\n\nexport const TOOL_DEFINITIONS: ToolDefinition[] = [\n {\n name: \"ping\",\n description:\n \"Liveness check; returns {pong: true} and the active rstool contract version.\",\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n invoke: (tool) => ({ pong: true, contractVersion: tool.contractVersion }),\n },\n {\n name: \"list_methods\",\n description: \"List all rstool methods exposed as MCP tools.\",\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n invoke: () => TOOL_DEFINITIONS.map((definition) => definition.name),\n },\n {\n name: \"ensure_session\",\n description:\n \"Return the current active session, or create one if none exists. Optional initial seed is used only when creating.\",\n inputSchema: {\n type: \"object\",\n properties: {\n initial: {\n type: \"object\",\n properties: {\n alias: { type: \"string\" },\n title: { type: \"string\" },\n comment: { type: \"string\" },\n },\n additionalProperties: true,\n },\n },\n additionalProperties: false,\n },\n invoke: (tool, args) => tool.ensureSession(args.initial as never),\n },\n {\n name: \"create_session\",\n description:\n \"Create a fresh in-memory rstool session and set it as the current active session.\",\n inputSchema: {\n type: \"object\",\n properties: {\n initial: {\n type: \"object\",\n description:\n \"Optional partial SessionState seed (alias, title, comment).\",\n properties: {\n alias: { type: \"string\" },\n title: { type: \"string\" },\n comment: { type: \"string\" },\n },\n additionalProperties: false,\n },\n },\n additionalProperties: false,\n },\n invoke: (tool, args) => tool.createSession(args.initial as never),\n },\n {\n name: \"set_current_session\",\n description: \"Set the active session by id.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n required: [\"sessionId\"],\n },\n invoke: (tool, args) => tool.setCurrentSession(String(args.sessionId)),\n },\n {\n name: \"get_current_session\",\n description: \"Return the current active session, or null if none exists.\",\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n invoke: (tool) => tool.getCurrentSession(),\n },\n {\n name: \"apply_schema_patch\",\n description:\n \"Preferred schema edit path. Batch patch with inferred ids and cstType, dependency ordering, and compact summary.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n initial: {\n type: \"object\",\n properties: {\n alias: { type: \"string\" },\n title: { type: \"string\" },\n comment: { type: \"string\" },\n },\n additionalProperties: true,\n },\n items: { type: \"array\", items: agentPatchSchema },\n mode: { type: \"string\", enum: [\"atomic\", \"best_effort\"] },\n commitMessage: { type: \"string\" },\n },\n required: [\"items\"],\n },\n invoke: (tool, args) =>\n tool.applySchemaPatch(\n omitSessionId(args) as never,\n optionalSessionId(args),\n ),\n },\n {\n name: \"get_session_state\",\n description:\n \"Return session state. detail=summary (default): compact metadata, aliases, diagnostics. detail=full: complete SessionState clone.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n detail: { type: \"string\", enum: [\"summary\", \"full\"] },\n },\n },\n invoke: (tool, args) =>\n tool.getSessionState(\n (args.detail as \"summary\" | \"full\" | undefined) ?? \"summary\",\n optionalSessionId(args),\n ),\n },\n {\n name: \"analyze_expression\",\n description:\n \"Parse and type-check a scratch expression without saving it. Does not record diagnostics unless recordDiagnostics=true.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n expression: { type: \"string\" },\n cstType: { type: \"string\" },\n recordDiagnostics: { type: \"boolean\" },\n },\n required: [\"expression\", \"cstType\"],\n },\n invoke: (tool, args) =>\n tool.analyzeExpression(\n omitSessionId(args) as never,\n optionalSessionId(args),\n ),\n },\n {\n name: \"list_diagnostics\",\n description:\n \"List active diagnostics for the session: expression (formula), schema (homonyms, duplicates, metadata), model (interpretation status).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n constituentId: { type: \"number\" },\n kind: { type: \"string\", enum: [\"expression\", \"schema\", \"model\"] },\n },\n },\n invoke: (tool, args) => {\n const constituentId = args.constituentId;\n const kind = args.kind;\n const filters: {\n constituentId?: number;\n kind?: \"expression\" | \"schema\" | \"model\";\n } = {};\n if (typeof constituentId === \"number\") {\n filters.constituentId = constituentId;\n }\n if (kind === \"expression\" || kind === \"schema\" || kind === \"model\") {\n filters.kind = kind;\n }\n return tool.listDiagnostics(\n Object.keys(filters).length > 0 ? filters : undefined,\n optionalSessionId(args),\n );\n },\n },\n {\n name: \"commit_step\",\n description:\n \"Record a session revision with an optional human-readable message.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n message: { type: \"string\" },\n },\n },\n invoke: (tool, args) =>\n tool.commitStep(\n args.message as string | undefined,\n optionalSessionId(args),\n ),\n },\n {\n name: \"export_session\",\n description:\n \"Serialize the session to a JSON string suitable for import_data with kind=session.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.exportSession(optionalSessionId(args)),\n },\n {\n name: \"export_portal\",\n description:\n \"Export Portal Load-from-JSON payload. kind=schema|model; format=json (default string) or object.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n kind: { type: \"string\", enum: [\"schema\", \"model\"] },\n format: { type: \"string\", enum: [\"json\", \"object\"] },\n },\n required: [\"kind\"],\n },\n invoke: (tool, args) =>\n tool.exportPortal(omitSessionId(args) as never, optionalSessionId(args)),\n },\n {\n name: \"import_data\",\n description:\n \"Import a session from export_session JSON, Portal schema JSON, or GET /api/rsforms/:id/details. kind=auto (default) detects the shape.\",\n inputSchema: {\n type: \"object\",\n properties: {\n payload: {\n description:\n \"JSON string or parsed object (session export, Portal schema, or rsform details).\",\n },\n kind: {\n type: \"string\",\n enum: [\"auto\", \"session\", \"portal-schema\", \"portal-details\"],\n },\n },\n required: [\"payload\"],\n },\n invoke: (tool, args) =>\n tool.importData(args.payload as string | object, args.kind as never),\n },\n {\n name: \"set_model_values\",\n description:\n \"Set and/or clear interpretable model bindings. Pass set[] for bindings and clear[] for constituent ids to reset.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n set: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n target: { type: \"number\" },\n type: { type: \"string\" },\n value: {},\n },\n required: [\"target\", \"value\"],\n },\n },\n clear: { type: \"array\", items: { type: \"number\" } },\n },\n },\n invoke: (tool, args) =>\n tool.setModelValues(\n omitSessionId(args) as never,\n optionalSessionId(args),\n ),\n },\n {\n name: \"get_model_state\",\n description: \"Return the SessionModelState.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.getModelState(optionalSessionId(args)),\n },\n {\n name: \"evaluate\",\n description:\n \"Evaluate a scratch expression (expression + cstType) or a stored constituent (constituentId).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n expression: { type: \"string\" },\n cstType: { type: \"string\" },\n constituentId: { type: \"number\" },\n },\n },\n invoke: (tool, args) =>\n tool.evaluate(omitSessionId(args) as never, optionalSessionId(args)),\n },\n {\n name: \"recalculate_model\",\n description: \"Recompute every inferrable constituent.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.recalculateModel(optionalSessionId(args)),\n },\n {\n name: \"restore_order\",\n description:\n \"Restore constituent declaration order: formal topology, semantic clusters when ready, otherwise stable type/kernel ranks.\",\n inputSchema: {\n type: \"object\",\n properties: { sessionId },\n },\n invoke: (tool, args) => tool.restoreOrder(optionalSessionId(args)),\n },\n {\n name: \"synthesize\",\n description:\n \"Synthesis by embedding: merge constituents from sourceSessionId into the receiver session, then apply an identification table (aliases).\",\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId,\n sourceSessionId: {\n type: \"string\",\n description: \"Session to merge from (must differ from the receiver).\",\n },\n items: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Optional source aliases to import. Omit or empty = import all.\",\n },\n substitutions: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n original: { type: \"string\" },\n substitution: { type: \"string\" },\n },\n required: [\"original\", \"substitution\"],\n },\n description:\n \"Identification table: each row pairs one source alias with one receiver alias.\",\n },\n commitMessage: { type: \"string\" },\n },\n required: [\"sourceSessionId\"],\n additionalProperties: true,\n },\n invoke: (tool, args) =>\n tool.synthesize(omitSessionId(args) as never, optionalSessionId(args)),\n },\n];\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\n\nimport { RSToolAgent } from \"@rsconcept/rstool\";\n\nimport { TOOL_DEFINITIONS, type ToolDefinition } from \"./tools\";\n\nexport interface BuildRSToolMcpServerOptions {\n /** Pre-built RSToolAgent. Defaults to a fresh in-memory instance. */\n tool?: RSToolAgent;\n /** Persist sessions to this directory (also reads RSTOOL_PERSISTENCE_DIR when set). */\n persistenceDir?: string;\n /** Server name advertised to MCP clients. */\n name?: string;\n /** Server version advertised to MCP clients. */\n version?: string;\n}\n\n/**\n * Build an MCP `McpServer` instance that exposes the `@rsconcept/rstool` contract.\n *\n * The returned server is not yet connected to a transport. Wrap it with a\n * `StdioServerTransport` (for local subprocess hosts like Cursor and Claude Desktop) or\n * an HTTP transport, then call `server.connect(transport)`.\n *\n * @example\n * ```ts\n * import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n * import { buildRSToolMcpServer } from '@rsconcept/rstool-mcp';\n *\n * const server = buildRSToolMcpServer();\n * await server.connect(new StdioServerTransport());\n * ```\n */\nexport function buildRSToolMcpServer(\n options: BuildRSToolMcpServerOptions = {},\n): McpServer {\n const persistenceDir =\n options.persistenceDir ?? process.env.RSTOOL_PERSISTENCE_DIR;\n const tool =\n options.tool ??\n new RSToolAgent(persistenceDir ? { persistenceDir } : undefined);\n const server = new McpServer(\n {\n name: options.name ?? \"rstool-mcp\",\n version: options.version ?? \"0.1.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n\n const definitionByName = new Map<string, ToolDefinition>(\n TOOL_DEFINITIONS.map((definition) => [definition.name, definition]),\n );\n\n server.server.setRequestHandler(ListToolsRequestSchema, () =>\n Promise.resolve({\n tools: TOOL_DEFINITIONS.map((definition) => ({\n name: definition.name,\n description: definition.description,\n inputSchema: definition.inputSchema,\n })),\n }),\n );\n\n server.server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const definition = definitionByName.get(request.params.name);\n if (!definition) {\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `Unknown rstool tool: ${request.params.name}`,\n },\n ],\n };\n }\n\n try {\n const result = await definition.invoke(\n tool,\n request.params.arguments ?? {},\n );\n const text =\n typeof result === \"string\" ? result : JSON.stringify(result, null, 2);\n return {\n content: [\n {\n type: \"text\" as const,\n text,\n },\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `rstool error in ${definition.name}: ${message}`,\n },\n ],\n };\n }\n });\n\n return server;\n}\n"],"mappings":";;;;AAqBA,MAAM,YAAY;CAChB,MAAM;CACN,aAAa;AACf;AAEA,MAAM,mBAAmB;CACvB,MAAM;CACN,aACE;CACF,YAAY;EACV,IAAI,EAAE,MAAM,SAAS;EACrB,OAAO,EAAE,MAAM,SAAS;EACxB,SAAS,EAAE,MAAM,SAAS;EAC1B,kBAAkB,EAAE,MAAM,SAAS;EACnC,MAAM,EAAE,MAAM,SAAS;EACvB,gBAAgB,EAAE,MAAM,SAAS;EACjC,YAAY,EAAE,MAAM,SAAS;CAC/B;CACA,UAAU,CAAC,OAAO;AACpB;AAEA,SAAS,kBAAkB,MAAmD;CAC5E,MAAM,QAAQ,KAAK;CACnB,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AACjE;AAEA,SAAS,cAAc,MAAwD;CAC7E,MAAM,EAAE,WAAW,YAAY,GAAG,SAAS;CAC3C,OAAO;AACT;AAEA,MAAa,mBAAqC;CAChD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY,CAAC;GACb,sBAAsB;EACxB;EACA,SAAS,UAAU;GAAE,MAAM;GAAM,iBAAiB,KAAK;EAAgB;CACzE;CACA;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY,CAAC;GACb,sBAAsB;EACxB;EACA,cAAc,iBAAiB,KAAK,eAAe,WAAW,IAAI;CACpE;CACA;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY,EACV,SAAS;IACP,MAAM;IACN,YAAY;KACV,OAAO,EAAE,MAAM,SAAS;KACxB,OAAO,EAAE,MAAM,SAAS;KACxB,SAAS,EAAE,MAAM,SAAS;IAC5B;IACA,sBAAsB;GACxB,EACF;GACA,sBAAsB;EACxB;EACA,SAAS,MAAM,SAAS,KAAK,cAAc,KAAK,OAAgB;CAClE;CACA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AiB,KAAK,gBAAgB;EAC3C,MAAM,WAAW;EACjB,aAAa,WAAW;EACxB,aAAa,WAAW;CAC1B,EAAE,EACJ,CAAC,CACH;CAEA,OAAO,OAAO,kBAAkB,uBAAuB,OAAO,YAAY;EACxE,MAAM,aAAa,iBAAiB,IAAI,QAAQ,OAAO,IAAI;EAC3D,IAAI,CAAC,YACH,OAAO;GACL,SAAS;GACT,SAAS,CACP;IACE,MAAM;IACN,MAAM,wBAAwB,QAAQ,OAAO;GAC/C,CACF;EACF;EAGF,IAAI;GACF,MAAM,SAAS,MAAM,WAAW,OAC9B,MACA,QAAQ,OAAO,aAAa,CAAC,CAC/B;GAGA,OAAO,EACL,SAAS,CACP;IACE,MAAM;IACN,MALJ,OAAO,WAAW,WAAW,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;GAMlE,CACF,EACF;EACF,SAAS,OAAO;GACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACrE,OAAO;IACL,SAAS;IACT,SAAS,CACP;KACE,MAAM;KACN,MAAM,mBAAmB,WAAW,KAAK,IAAI;IAC/C,CACF;GACF;EACF;CACF,CAAC;CAED,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsconcept/rstool-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Model Context Protocol (MCP) adapter that exposes the @rsconcept/rstool RSToolAgent contract over MCP stdio. Works with Cursor, Claude Desktop, and any MCP-capable host.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "IRBorisov",
|
package/src/server.test.ts
CHANGED
package/src/tools.ts
CHANGED
|
@@ -370,4 +370,43 @@ export const TOOL_DEFINITIONS: ToolDefinition[] = [
|
|
|
370
370
|
},
|
|
371
371
|
invoke: (tool, args) => tool.restoreOrder(optionalSessionId(args)),
|
|
372
372
|
},
|
|
373
|
+
{
|
|
374
|
+
name: "synthesize",
|
|
375
|
+
description:
|
|
376
|
+
"Synthesis by embedding: merge constituents from sourceSessionId into the receiver session, then apply an identification table (aliases).",
|
|
377
|
+
inputSchema: {
|
|
378
|
+
type: "object",
|
|
379
|
+
properties: {
|
|
380
|
+
sessionId,
|
|
381
|
+
sourceSessionId: {
|
|
382
|
+
type: "string",
|
|
383
|
+
description: "Session to merge from (must differ from the receiver).",
|
|
384
|
+
},
|
|
385
|
+
items: {
|
|
386
|
+
type: "array",
|
|
387
|
+
items: { type: "string" },
|
|
388
|
+
description:
|
|
389
|
+
"Optional source aliases to import. Omit or empty = import all.",
|
|
390
|
+
},
|
|
391
|
+
substitutions: {
|
|
392
|
+
type: "array",
|
|
393
|
+
items: {
|
|
394
|
+
type: "object",
|
|
395
|
+
properties: {
|
|
396
|
+
original: { type: "string" },
|
|
397
|
+
substitution: { type: "string" },
|
|
398
|
+
},
|
|
399
|
+
required: ["original", "substitution"],
|
|
400
|
+
},
|
|
401
|
+
description:
|
|
402
|
+
"Identification table: each row pairs one source alias with one receiver alias.",
|
|
403
|
+
},
|
|
404
|
+
commitMessage: { type: "string" },
|
|
405
|
+
},
|
|
406
|
+
required: ["sourceSessionId"],
|
|
407
|
+
additionalProperties: true,
|
|
408
|
+
},
|
|
409
|
+
invoke: (tool, args) =>
|
|
410
|
+
tool.synthesize(omitSessionId(args) as never, optionalSessionId(args)),
|
|
411
|
+
},
|
|
373
412
|
];
|