@weave-framework/mcp 0.2.162
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/LICENSE +21 -0
- package/README.md +46 -0
- package/bin/weave-mcp-dist.mjs +14 -0
- package/bin/weave-mcp.mjs +32 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonrpc.d.ts +49 -0
- package/dist/jsonrpc.d.ts.map +1 -0
- package/dist/jsonrpc.js +18 -0
- package/dist/jsonrpc.js.map +1 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +84 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.d.ts +18 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +44 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tools/check.d.ts +8 -0
- package/dist/tools/check.d.ts.map +1 -0
- package/dist/tools/check.js +28 -0
- package/dist/tools/check.js.map +1 -0
- package/dist/tools/compile-template.d.ts +9 -0
- package/dist/tools/compile-template.d.ts.map +1 -0
- package/dist/tools/compile-template.js +42 -0
- package/dist/tools/compile-template.js.map +1 -0
- package/dist/tools/routes.d.ts +8 -0
- package/dist/tools/routes.d.ts.map +1 -0
- package/dist/tools/routes.js +28 -0
- package/dist/tools/routes.js.map +1 -0
- package/dist/tools/scaffold-component.d.ts +16 -0
- package/dist/tools/scaffold-component.d.ts.map +1 -0
- package/dist/tools/scaffold-component.js +62 -0
- package/dist/tools/scaffold-component.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aidas Josas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @weave-framework/mcp
|
|
2
|
+
|
|
3
|
+
A **Model Context Protocol** server that exposes the Weave toolchain to MCP-capable AI agents and
|
|
4
|
+
editors — so your AI assistant can compile-check a template, type-check the project, resolve
|
|
5
|
+
file-based routes, and scaffold a component through structured tools instead of guessing at the CLI.
|
|
6
|
+
|
|
7
|
+
Part of [Weave](https://weaveframework.dev).
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
| Tool | What it does |
|
|
12
|
+
|------|--------------|
|
|
13
|
+
| `weave_compile_template` | Compile a Weave template string → emitted code, or the real compiler error. Validate markup before shipping it. |
|
|
14
|
+
| `weave_check` | Type-check a Weave project (templates + child-props) → diagnostics with file/line/col/message. |
|
|
15
|
+
| `weave_routes` | Turn a list of page files into Weave's file-based route tree (`[id]`→`:id`, `index`→`""`, `_layout`→nested). |
|
|
16
|
+
| `weave_scaffold_component` | Generate a component's boilerplate files (`.ts` + `.html` [+ stylesheet]). Returns the files — never writes without you. |
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Configure your MCP client to launch the server over **stdio**:
|
|
21
|
+
|
|
22
|
+
```jsonc
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"weave": {
|
|
26
|
+
"command": "weave-mcp",
|
|
27
|
+
"cwd": "/path/to/your/weave/project"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Equivalently, `weave mcp` (from `@weave-framework/cli`) starts the same server. The server's working
|
|
34
|
+
directory should be your project root so `weave_check` resolves the right files.
|
|
35
|
+
|
|
36
|
+
## Zero-dependency by design
|
|
37
|
+
|
|
38
|
+
MCP is JSON-RPC 2.0 over a transport. This package implements the protocol **in-house** (a small
|
|
39
|
+
JSON-RPC framing + a newline-delimited stdio loop) rather than pulling a third-party MCP SDK —
|
|
40
|
+
keeping Weave's zero-runtime-dependency rule. The tools thin-wrap the existing
|
|
41
|
+
`@weave-framework/compiler`, `@weave-framework/check`, and `@weave-framework/router` — no
|
|
42
|
+
re-implementation.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* PUBLISHED bin: a thin launcher over the prebuilt dist/index.js — starts the Weave MCP
|
|
4
|
+
* server over stdio. Selected via package.json `publishConfig.bin`.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const pkg = JSON.parse(readFileSync(join(here, '../package.json'), 'utf8'));
|
|
12
|
+
|
|
13
|
+
const { runStdioServer } = await import('../dist/index.js');
|
|
14
|
+
await runStdioServer({ version: pkg.version });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* DEV bin (monorepo): bundle the typed MCP server source on the fly (esbuild inlines
|
|
4
|
+
* @weave-framework/compiler/check/router; typescript/sass/esbuild stay external) and run it
|
|
5
|
+
* over stdio. Lets `weave-mcp` run from live `src/` with no build step during development.
|
|
6
|
+
*
|
|
7
|
+
* For the PUBLISHED package, package.json `publishConfig.bin` swaps this for
|
|
8
|
+
* bin/weave-mcp-dist.mjs (a thin launcher over the prebuilt dist/index.js).
|
|
9
|
+
*/
|
|
10
|
+
import { build as esbuild } from 'esbuild';
|
|
11
|
+
import { mkdirSync, readFileSync } from 'node:fs';
|
|
12
|
+
import { dirname, join, resolve } from 'node:path';
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
14
|
+
|
|
15
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const pkg = JSON.parse(readFileSync(join(here, '../package.json'), 'utf8'));
|
|
17
|
+
const cacheDir = join(resolve(here, '../../..'), 'node_modules', '.weave');
|
|
18
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
19
|
+
const out = join(cacheDir, 'mcp.mjs');
|
|
20
|
+
|
|
21
|
+
await esbuild({
|
|
22
|
+
entryPoints: [join(here, '../src/index.ts')],
|
|
23
|
+
bundle: true,
|
|
24
|
+
format: 'esm',
|
|
25
|
+
platform: 'node',
|
|
26
|
+
target: 'node18',
|
|
27
|
+
external: ['typescript', 'sass', 'esbuild'],
|
|
28
|
+
outfile: out,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const { runStdioServer } = await import(pathToFileURL(out).href);
|
|
32
|
+
await runStdioServer({ version: pkg.version });
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weave-framework/mcp — a Model Context Protocol server that exposes the Weave toolchain
|
|
3
|
+
* to AI agents & editors as MCP tools. In-house JSON-RPC over stdio, zero third-party deps
|
|
4
|
+
* (RFC 0006; [[weave-zero-dependencies]]).
|
|
5
|
+
*
|
|
6
|
+
* Tools (v1): weave_compile_template · weave_check · weave_routes · weave_scaffold_component.
|
|
7
|
+
* Launch with the `weave-mcp` bin (or `weave mcp`), or embed via {@link createServer} /
|
|
8
|
+
* {@link runStdioServer}.
|
|
9
|
+
*/
|
|
10
|
+
import { McpServer, type McpServerOptions } from './server.js';
|
|
11
|
+
import { type StdioOptions } from './stdio.js';
|
|
12
|
+
/** Build a Weave MCP server with all v1 tools registered. */
|
|
13
|
+
export declare function createServer(opts?: McpServerOptions): McpServer;
|
|
14
|
+
/** Build the server and run it over the stdio transport (the `weave-mcp` entry point). */
|
|
15
|
+
export declare function runStdioServer(opts?: McpServerOptions & StdioOptions): Promise<void>;
|
|
16
|
+
export { McpServer, PROTOCOL_VERSION, type McpServerOptions } from './server.js';
|
|
17
|
+
export { runStdio, type StdioOptions } from './stdio.js';
|
|
18
|
+
export { textResult, jsonResult, type JsonRpcRequest, type JsonRpcResponse, type JsonRpcError, type McpTool, type McpToolResult, } from './jsonrpc.js';
|
|
19
|
+
export { compileTemplateTool } from './tools/compile-template.js';
|
|
20
|
+
export { checkTool } from './tools/check.js';
|
|
21
|
+
export { routesTool } from './tools/routes.js';
|
|
22
|
+
export { scaffoldComponentTool, generateComponent, type GeneratedFile } from './tools/scaffold-component.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAMzD,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,IAAI,GAAE,gBAAqB,GAAG,SAAS,CAMnE;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,GAAE,gBAAgB,GAAG,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weave-framework/mcp — a Model Context Protocol server that exposes the Weave toolchain
|
|
3
|
+
* to AI agents & editors as MCP tools. In-house JSON-RPC over stdio, zero third-party deps
|
|
4
|
+
* (RFC 0006; [[weave-zero-dependencies]]).
|
|
5
|
+
*
|
|
6
|
+
* Tools (v1): weave_compile_template · weave_check · weave_routes · weave_scaffold_component.
|
|
7
|
+
* Launch with the `weave-mcp` bin (or `weave mcp`), or embed via {@link createServer} /
|
|
8
|
+
* {@link runStdioServer}.
|
|
9
|
+
*/
|
|
10
|
+
import { McpServer } from './server.js';
|
|
11
|
+
import { runStdio } from './stdio.js';
|
|
12
|
+
import { compileTemplateTool } from './tools/compile-template.js';
|
|
13
|
+
import { checkTool } from './tools/check.js';
|
|
14
|
+
import { routesTool } from './tools/routes.js';
|
|
15
|
+
import { scaffoldComponentTool } from './tools/scaffold-component.js';
|
|
16
|
+
/** Build a Weave MCP server with all v1 tools registered. */
|
|
17
|
+
export function createServer(opts = {}) {
|
|
18
|
+
return new McpServer(opts)
|
|
19
|
+
.registerTool(compileTemplateTool)
|
|
20
|
+
.registerTool(checkTool)
|
|
21
|
+
.registerTool(routesTool)
|
|
22
|
+
.registerTool(scaffoldComponentTool);
|
|
23
|
+
}
|
|
24
|
+
/** Build the server and run it over the stdio transport (the `weave-mcp` entry point). */
|
|
25
|
+
export function runStdioServer(opts = {}) {
|
|
26
|
+
return runStdio(createServer(opts), opts);
|
|
27
|
+
}
|
|
28
|
+
export { McpServer, PROTOCOL_VERSION } from './server.js';
|
|
29
|
+
export { runStdio } from './stdio.js';
|
|
30
|
+
export { textResult, jsonResult, } from './jsonrpc.js';
|
|
31
|
+
export { compileTemplateTool } from './tools/compile-template.js';
|
|
32
|
+
export { checkTool } from './tools/check.js';
|
|
33
|
+
export { routesTool } from './tools/routes.js';
|
|
34
|
+
export { scaffoldComponentTool, generateComponent } from './tools/scaffold-component.js';
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAqB,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,6DAA6D;AAC7D,MAAM,UAAU,YAAY,CAAC,OAAyB,EAAE;IACtD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC;SACvB,YAAY,CAAC,mBAAmB,CAAC;SACjC,YAAY,CAAC,SAAS,CAAC;SACvB,YAAY,CAAC,UAAU,CAAC;SACxB,YAAY,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,OAAwC,EAAE;IACvE,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAqB,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,UAAU,EACV,UAAU,GAMX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAsB,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal JSON-RPC 2.0 types + an MCP tool shape. Zero-dep: MCP is JSON-RPC over a
|
|
3
|
+
* transport (stdio here), and the protocol is small enough to own in-house rather than
|
|
4
|
+
* pull a third-party SDK ([[weave-zero-dependencies]] / RFC 0006).
|
|
5
|
+
*/
|
|
6
|
+
/** A JSON-RPC 2.0 request. A request with no `id` is a notification (no response). */
|
|
7
|
+
export interface JsonRpcRequest {
|
|
8
|
+
jsonrpc: '2.0';
|
|
9
|
+
id?: number | string | null;
|
|
10
|
+
method: string;
|
|
11
|
+
params?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/** A JSON-RPC 2.0 response — exactly one of `result` / `error`. */
|
|
14
|
+
export interface JsonRpcResponse {
|
|
15
|
+
jsonrpc: '2.0';
|
|
16
|
+
id: number | string | null;
|
|
17
|
+
result?: unknown;
|
|
18
|
+
error?: JsonRpcError;
|
|
19
|
+
}
|
|
20
|
+
export interface JsonRpcError {
|
|
21
|
+
code: number;
|
|
22
|
+
message: string;
|
|
23
|
+
data?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Standard JSON-RPC error codes used by the server. */
|
|
26
|
+
export declare const RPC_METHOD_NOT_FOUND: number;
|
|
27
|
+
export declare const RPC_INVALID_PARAMS: number;
|
|
28
|
+
export declare const RPC_INTERNAL_ERROR: number;
|
|
29
|
+
/** An MCP tool: a name, a JSON-Schema for its input, and an async handler. */
|
|
30
|
+
export interface McpTool {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
/** JSON Schema describing the tool's `arguments` object. */
|
|
34
|
+
inputSchema: object;
|
|
35
|
+
handler: (args: Record<string, unknown>) => Promise<McpToolResult> | McpToolResult;
|
|
36
|
+
}
|
|
37
|
+
/** The MCP `tools/call` result shape — text content, optionally flagged as an error. */
|
|
38
|
+
export interface McpToolResult {
|
|
39
|
+
content: Array<{
|
|
40
|
+
type: 'text';
|
|
41
|
+
text: string;
|
|
42
|
+
}>;
|
|
43
|
+
isError?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Convenience: wrap a string (or JSON-serialisable value) as a text tool result. */
|
|
46
|
+
export declare function textResult(text: string, isError?: boolean): McpToolResult;
|
|
47
|
+
/** Convenience: wrap a value as pretty JSON text content. */
|
|
48
|
+
export declare function jsonResult(value: unknown): McpToolResult;
|
|
49
|
+
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,O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AAK,EAAE,OAAO,GAAG,aAAa,CAExD"}
|
package/dist/jsonrpc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal JSON-RPC 2.0 types + an MCP tool shape. Zero-dep: MCP is JSON-RPC over a
|
|
3
|
+
* transport (stdio here), and the protocol is small enough to own in-house rather than
|
|
4
|
+
* pull a third-party SDK ([[weave-zero-dependencies]] / RFC 0006).
|
|
5
|
+
*/
|
|
6
|
+
/** Standard JSON-RPC error codes used by the server. */
|
|
7
|
+
export const RPC_METHOD_NOT_FOUND = -32601;
|
|
8
|
+
export const RPC_INVALID_PARAMS = -32602;
|
|
9
|
+
export const RPC_INTERNAL_ERROR = -32603;
|
|
10
|
+
/** Convenience: wrap a string (or JSON-serialisable value) as a text tool result. */
|
|
11
|
+
export function textResult(text, isError = false) {
|
|
12
|
+
return { content: [{ type: 'text', text }], isError };
|
|
13
|
+
}
|
|
14
|
+
/** Convenience: wrap a value as pretty JSON text content. */
|
|
15
|
+
export function jsonResult(value) {
|
|
16
|
+
return textResult(JSON.stringify(value, null, 2));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=jsonrpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,wDAAwD;AACxD,MAAM,CAAC,MAAM,oBAAoB,GAAW,CAAC,KAAK,CAAC;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAW,CAAC,KAAK,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAW,CAAC,KAAK,CAAC;AAiBjD,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,UAAmB,KAAK;IAC/D,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;AACxD,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server core — pure request→response dispatch, no transport, no Node APIs.
|
|
3
|
+
* A transport (see `./stdio.ts`) feeds it parsed {@link JsonRpcRequest}s and writes back
|
|
4
|
+
* the {@link JsonRpcResponse}s. Kept Node-free so it is unit-testable in the browser harness.
|
|
5
|
+
*/
|
|
6
|
+
import { RPC_INTERNAL_ERROR, type JsonRpcRequest, type JsonRpcResponse, type McpTool } from './jsonrpc.js';
|
|
7
|
+
/** The MCP protocol revision this server speaks. */
|
|
8
|
+
export declare const PROTOCOL_VERSION: string;
|
|
9
|
+
export interface McpServerOptions {
|
|
10
|
+
name?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A minimal MCP server: register tools, then `handle()` each JSON-RPC request. Implements
|
|
15
|
+
* `initialize`, `tools/list`, `tools/call`, and swallows `notifications/*` (returns null,
|
|
16
|
+
* i.e. no response). Tool *execution* failures are returned as `isError` results (MCP
|
|
17
|
+
* convention); protocol failures (unknown method / unknown tool) are JSON-RPC errors.
|
|
18
|
+
*/
|
|
19
|
+
export declare class McpServer {
|
|
20
|
+
private readonly tools;
|
|
21
|
+
private readonly name;
|
|
22
|
+
private readonly version;
|
|
23
|
+
constructor(opts?: McpServerOptions);
|
|
24
|
+
/** Register a tool (last registration of a name wins). Chainable. */
|
|
25
|
+
registerTool(tool: McpTool): this;
|
|
26
|
+
/** The public tool descriptors (no handlers) — the `tools/list` payload. */
|
|
27
|
+
listTools(): Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
inputSchema: object;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Handle one request. Returns the response, or `null` for a notification (a request with
|
|
34
|
+
* no `id`, e.g. `notifications/initialized`) which must not be answered.
|
|
35
|
+
*/
|
|
36
|
+
handle(req: JsonRpcRequest): Promise<JsonRpcResponse | null>;
|
|
37
|
+
private ok;
|
|
38
|
+
private err;
|
|
39
|
+
}
|
|
40
|
+
export { RPC_INTERNAL_ERROR };
|
|
41
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,kBAAkB,EAIlB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,OAAO,EAEb,MAAM,cAAc,CAAC;AAEtB,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,EAAE,MAAqB,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoD;IAC1E,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,IAAI,GAAE,gBAAqB;IAKvC,qEAAqE;IACrE,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAKjC,4EAA4E;IAC5E,SAAS,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ9E;;;OAGG;IACG,MAAM,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA0ClE,OAAO,CAAC,EAAE;IAIV,OAAO,CAAC,GAAG;CAGZ;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server core — pure request→response dispatch, no transport, no Node APIs.
|
|
3
|
+
* A transport (see `./stdio.ts`) feeds it parsed {@link JsonRpcRequest}s and writes back
|
|
4
|
+
* the {@link JsonRpcResponse}s. Kept Node-free so it is unit-testable in the browser harness.
|
|
5
|
+
*/
|
|
6
|
+
import { RPC_INTERNAL_ERROR, RPC_INVALID_PARAMS, RPC_METHOD_NOT_FOUND, textResult, } from './jsonrpc.js';
|
|
7
|
+
/** The MCP protocol revision this server speaks. */
|
|
8
|
+
export const PROTOCOL_VERSION = '2024-11-05';
|
|
9
|
+
/**
|
|
10
|
+
* A minimal MCP server: register tools, then `handle()` each JSON-RPC request. Implements
|
|
11
|
+
* `initialize`, `tools/list`, `tools/call`, and swallows `notifications/*` (returns null,
|
|
12
|
+
* i.e. no response). Tool *execution* failures are returned as `isError` results (MCP
|
|
13
|
+
* convention); protocol failures (unknown method / unknown tool) are JSON-RPC errors.
|
|
14
|
+
*/
|
|
15
|
+
export class McpServer {
|
|
16
|
+
tools = new Map();
|
|
17
|
+
name;
|
|
18
|
+
version;
|
|
19
|
+
constructor(opts = {}) {
|
|
20
|
+
this.name = opts.name ?? '@weave-framework/mcp';
|
|
21
|
+
this.version = opts.version ?? 'dev';
|
|
22
|
+
}
|
|
23
|
+
/** Register a tool (last registration of a name wins). Chainable. */
|
|
24
|
+
registerTool(tool) {
|
|
25
|
+
this.tools.set(tool.name, tool);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
/** The public tool descriptors (no handlers) — the `tools/list` payload. */
|
|
29
|
+
listTools() {
|
|
30
|
+
return [...this.tools.values()].map((t) => ({
|
|
31
|
+
name: t.name,
|
|
32
|
+
description: t.description,
|
|
33
|
+
inputSchema: t.inputSchema,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Handle one request. Returns the response, or `null` for a notification (a request with
|
|
38
|
+
* no `id`, e.g. `notifications/initialized`) which must not be answered.
|
|
39
|
+
*/
|
|
40
|
+
async handle(req) {
|
|
41
|
+
const id = req.id ?? null;
|
|
42
|
+
const isNotification = req.id === undefined || req.id === null;
|
|
43
|
+
if (req.method === 'initialize') {
|
|
44
|
+
return this.ok(id, {
|
|
45
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
46
|
+
capabilities: { tools: {} },
|
|
47
|
+
serverInfo: { name: this.name, version: this.version },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (req.method.startsWith('notifications/')) {
|
|
51
|
+
return null; // notifications get no response
|
|
52
|
+
}
|
|
53
|
+
if (req.method === 'tools/list') {
|
|
54
|
+
return this.ok(id, { tools: this.listTools() });
|
|
55
|
+
}
|
|
56
|
+
if (req.method === 'tools/call') {
|
|
57
|
+
const params = (req.params ?? {});
|
|
58
|
+
const tool = params.name ? this.tools.get(params.name) : undefined;
|
|
59
|
+
if (!tool) {
|
|
60
|
+
return this.err(id, RPC_INVALID_PARAMS, `unknown tool: ${String(params.name)}`);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const result = await tool.handler(params.arguments ?? {});
|
|
64
|
+
return this.ok(id, result);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
// A tool that throws → an isError result (the agent sees the message, keeps the session).
|
|
68
|
+
return this.ok(id, textResult(`${e?.message ?? String(e)}`, true));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (isNotification)
|
|
72
|
+
return null;
|
|
73
|
+
return this.err(id, RPC_METHOD_NOT_FOUND, `method not found: ${req.method}`);
|
|
74
|
+
}
|
|
75
|
+
ok(id, result) {
|
|
76
|
+
return { jsonrpc: '2.0', id, result };
|
|
77
|
+
}
|
|
78
|
+
err(id, code, message) {
|
|
79
|
+
return { jsonrpc: '2.0', id, error: { code, message } };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Re-export so consumers can build a server without reaching into ./jsonrpc.
|
|
83
|
+
export { RPC_INTERNAL_ERROR };
|
|
84
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,GAKX,MAAM,cAAc,CAAC;AAEtB,oDAAoD;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAW,YAAY,CAAC;AAOrD;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACH,KAAK,GAAyB,IAAI,GAAG,EAAmB,CAAC;IACzD,IAAI,CAAS;IACb,OAAO,CAAS;IAEjC,YAAY,OAAyB,EAAE;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,sBAAsB,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;IACvC,CAAC;IAED,qEAAqE;IACrE,YAAY,CAAC,IAAa;QACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4EAA4E;IAC5E,SAAS;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,GAAmB;QAC9B,MAAM,EAAE,GAA2B,GAAG,CAAC,EAAE,IAAI,IAAI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,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;gBACzE,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,0FAA0F;gBAC1F,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,GAAI,CAAW,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;QAED,IAAI,cAAc;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,oBAAoB,EAAE,qBAAqB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEO,EAAE,CAAC,EAA0B,EAAE,MAAe;QACpD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IACxC,CAAC;IAEO,GAAG,CAAC,EAA0B,EAAE,IAAY,EAAE,OAAe;QACnE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;IAC1D,CAAC;CACF;AAED,6EAA6E;AAC7E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/stdio.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stdio transport: newline-delimited JSON-RPC on stdin/stdout — the standard MCP stdio
|
|
3
|
+
* framing (one JSON message per line). Reads requests, dispatches to the {@link McpServer},
|
|
4
|
+
* writes responses. Requests are processed strictly in order (responses never interleave).
|
|
5
|
+
* Node-only.
|
|
6
|
+
*/
|
|
7
|
+
import type { Readable, Writable } from 'node:stream';
|
|
8
|
+
import type { McpServer } from './server.js';
|
|
9
|
+
export interface StdioOptions {
|
|
10
|
+
input?: Readable;
|
|
11
|
+
output?: Writable;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run `server` over a newline-delimited JSON-RPC stdio loop. Resolves when the input stream
|
|
15
|
+
* closes. Lines are handled sequentially via a promise chain so responses stay in request order.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runStdio(server: McpServer, opts?: StdioOptions): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=stdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BlF"}
|
package/dist/stdio.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stdio transport: newline-delimited JSON-RPC on stdin/stdout — the standard MCP stdio
|
|
3
|
+
* framing (one JSON message per line). Reads requests, dispatches to the {@link McpServer},
|
|
4
|
+
* writes responses. Requests are processed strictly in order (responses never interleave).
|
|
5
|
+
* Node-only.
|
|
6
|
+
*/
|
|
7
|
+
import { createInterface } from 'node:readline';
|
|
8
|
+
const RPC_PARSE_ERROR = -32700;
|
|
9
|
+
/**
|
|
10
|
+
* Run `server` over a newline-delimited JSON-RPC stdio loop. Resolves when the input stream
|
|
11
|
+
* closes. Lines are handled sequentially via a promise chain so responses stay in request order.
|
|
12
|
+
*/
|
|
13
|
+
export function runStdio(server, opts = {}) {
|
|
14
|
+
const input = opts.input ?? process.stdin;
|
|
15
|
+
const output = opts.output ?? process.stdout;
|
|
16
|
+
const rl = createInterface({ input, crlfDelay: Infinity });
|
|
17
|
+
let chain = Promise.resolve();
|
|
18
|
+
const write = (obj) => void output.write(JSON.stringify(obj) + '\n');
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
rl.on('line', (line) => {
|
|
21
|
+
const trimmed = line.trim();
|
|
22
|
+
if (!trimmed)
|
|
23
|
+
return;
|
|
24
|
+
chain = chain.then(async () => {
|
|
25
|
+
let req;
|
|
26
|
+
try {
|
|
27
|
+
req = JSON.parse(trimmed);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
write({ jsonrpc: '2.0', id: null, error: { code: RPC_PARSE_ERROR, message: 'parse error' } });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const res = await server.handle(req);
|
|
34
|
+
if (res)
|
|
35
|
+
write(res);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
rl.on('close', () => {
|
|
39
|
+
// drain the chain, then resolve
|
|
40
|
+
void chain.then(resolve);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AAKhE,MAAM,eAAe,GAAW,CAAC,KAAK,CAAC;AAOvC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,OAAqB,EAAE;IACjE,MAAM,KAAK,GAAa,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;IACpD,MAAM,MAAM,GAAa,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IACvD,MAAM,EAAE,GAAc,eAAe,CAAC,EAAE,KAAK,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
|
|
1
|
+
/**
|
|
2
|
+
* `weave_check` — type-check a Weave project (template + child-prop diagnostics) and return
|
|
3
|
+
* the diagnostics. Wraps `@weave-framework/check`'s `checkProject`, which walks the given
|
|
4
|
+
* directories relative to the server's cwd (the target project). Node-only (filesystem).
|
|
5
|
+
*/
|
|
6
|
+
import { type McpTool } from '../jsonrpc.js';
|
|
7
|
+
export declare const checkTool: McpTool;
|
|
8
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/tools/check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAc,KAAK,OAAO,EAAsB,MAAM,eAAe,CAAC;AAE7E,eAAO,MAAM,SAAS,EAAE,OAqBvB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_check` — type-check a Weave project (template + child-prop diagnostics) and return
|
|
3
|
+
* the diagnostics. Wraps `@weave-framework/check`'s `checkProject`, which walks the given
|
|
4
|
+
* directories relative to the server's cwd (the target project). Node-only (filesystem).
|
|
5
|
+
*/
|
|
6
|
+
import { checkProject } from '@weave-framework/check';
|
|
7
|
+
import { jsonResult } from '../jsonrpc.js';
|
|
8
|
+
export const checkTool = {
|
|
9
|
+
name: 'weave_check',
|
|
10
|
+
description: 'Type-check a Weave project — template expressions and child-prop usage included. Returns diagnostics { file, line, col, code, message, category }. Runs against the server working directory.',
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
roots: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
items: { type: 'string' },
|
|
17
|
+
description: 'Directories to check, relative to the project root. Default ["src"].',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
handler: (args) => {
|
|
22
|
+
const roots = Array.isArray(args.roots) && args.roots.length ? args.roots.map(String) : ['src'];
|
|
23
|
+
const diagnostics = checkProject(roots);
|
|
24
|
+
const errorCount = diagnostics.filter((d) => d.category === 'error').length;
|
|
25
|
+
return jsonResult({ ok: errorCount === 0, errorCount, diagnostics });
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/tools/check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAmB,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAoC,MAAM,eAAe,CAAC;AAE7E,MAAM,CAAC,MAAM,SAAS,GAAY;IAChC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,+LAA+L;IACjM,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,sEAAsE;aACpF;SACF;KACF;IACD,OAAO,EAAE,CAAC,IAA6B,EAAiB,EAAE;QACxD,MAAM,KAAK,GACT,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,IAAI,CAAC,KAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClG,MAAM,WAAW,GAAiB,YAAY,CAAC,KAAK,CAAC,CAAC;QACtD,MAAM,UAAU,GAAW,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC;QACpF,OAAO,UAAU,CAAC,EAAE,EAAE,EAAE,UAAU,KAAK,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IACvE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_compile_template` — compile a Weave template string and return the emitted code,
|
|
3
|
+
* or the parse/codegen error. The highest-value MCP tool: an agent that just wrote template
|
|
4
|
+
* markup can *validate* it against the real Weave compiler (real errors, not guesses) before
|
|
5
|
+
* shipping it. Purely functional — no filesystem, no project resolution.
|
|
6
|
+
*/
|
|
7
|
+
import { type McpTool } from '../jsonrpc.js';
|
|
8
|
+
export declare const compileTemplateTool: McpTool;
|
|
9
|
+
//# sourceMappingURL=compile-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-template.d.ts","sourceRoot":"","sources":["../../src/tools/compile-template.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAA0B,KAAK,OAAO,EAAsB,MAAM,eAAe,CAAC;AAEzF,eAAO,MAAM,mBAAmB,EAAE,OAiCjC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_compile_template` — compile a Weave template string and return the emitted code,
|
|
3
|
+
* or the parse/codegen error. The highest-value MCP tool: an agent that just wrote template
|
|
4
|
+
* markup can *validate* it against the real Weave compiler (real errors, not guesses) before
|
|
5
|
+
* shipping it. Purely functional — no filesystem, no project resolution.
|
|
6
|
+
*/
|
|
7
|
+
import { compileTemplate } from '@weave-framework/compiler';
|
|
8
|
+
import { jsonResult, textResult } from '../jsonrpc.js';
|
|
9
|
+
export const compileTemplateTool = {
|
|
10
|
+
name: 'weave_compile_template',
|
|
11
|
+
description: 'Compile a Weave template string to runtime code, or return the compiler error. Use this to VALIDATE Weave template markup you wrote before shipping it — you get the real parse/codegen error rather than guessing.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
template: { type: 'string', description: 'The Weave template source (the markup) to compile.' },
|
|
16
|
+
mode: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
enum: ['module', 'function'],
|
|
19
|
+
description: 'Codegen mode (default "module").',
|
|
20
|
+
},
|
|
21
|
+
scope: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: { type: 'string' },
|
|
24
|
+
description: 'Names of identifiers already in scope (component fields/imports), so references resolve.',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ['template'],
|
|
28
|
+
},
|
|
29
|
+
handler: (args) => {
|
|
30
|
+
const template = String(args.template ?? '');
|
|
31
|
+
const mode = args.mode === 'function' || args.mode === 'module' ? args.mode : undefined;
|
|
32
|
+
const scope = Array.isArray(args.scope) ? args.scope : undefined;
|
|
33
|
+
try {
|
|
34
|
+
const res = compileTemplate(template, { mode, scope });
|
|
35
|
+
return jsonResult({ ok: true, code: res.code, components: res.components });
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
return textResult(`Compile error: ${e?.message ?? String(e)}`, true);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=compile-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-template.js","sourceRoot":"","sources":["../../src/tools/compile-template.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAsB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAoC,MAAM,eAAe,CAAC;AAEzF,MAAM,CAAC,MAAM,mBAAmB,GAAY;IAC1C,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACT,qNAAqN;IACvN,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oDAAoD,EAAE;YAC/F,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;gBAC5B,WAAW,EAAE,kCAAkC;aAChD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,0FAA0F;aACxG;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;IACD,OAAO,EAAE,CAAC,IAA6B,EAAiB,EAAE;QACxD,MAAM,QAAQ,GAAW,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,GACR,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,MAAM,KAAK,GAAyB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,KAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;QACrG,IAAI,CAAC;YACH,MAAM,GAAG,GAAkB,eAAe,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,OAAO,UAAU,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QAC9E,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,UAAU,CAAC,kBAAmB,CAAW,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_routes` — turn a list of page-file paths into Weave's file-based route tree, so an
|
|
3
|
+
* agent can see how files map to routes (`[id]`→`:id`, `index`→`""`, `_layout`→nested wrapper)
|
|
4
|
+
* without running the CLI. Pure over the DOM-free `@weave-framework/router/files` helper.
|
|
5
|
+
*/
|
|
6
|
+
import { type McpTool } from '../jsonrpc.js';
|
|
7
|
+
export declare const routesTool: McpTool;
|
|
8
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/tools/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAc,KAAK,OAAO,EAAsB,MAAM,eAAe,CAAC;AAE7E,eAAO,MAAM,UAAU,EAAE,OAoBxB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_routes` — turn a list of page-file paths into Weave's file-based route tree, so an
|
|
3
|
+
* agent can see how files map to routes (`[id]`→`:id`, `index`→`""`, `_layout`→nested wrapper)
|
|
4
|
+
* without running the CLI. Pure over the DOM-free `@weave-framework/router/files` helper.
|
|
5
|
+
*/
|
|
6
|
+
import { fileToRoutes } from '@weave-framework/router/files';
|
|
7
|
+
import { jsonResult } from '../jsonrpc.js';
|
|
8
|
+
export const routesTool = {
|
|
9
|
+
name: 'weave_routes',
|
|
10
|
+
description: "Build Weave's file-based route tree from a list of page file paths (relative to the pages dir). Shows the resolved routes: [id]→:id, [...rest]→*, index→\"\", _layout→a nested wrapper route.",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
files: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
items: { type: 'string' },
|
|
17
|
+
description: 'Page file paths relative to the pages directory, e.g. ["index.ts","user/[id].ts","_layout.ts"].',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ['files'],
|
|
21
|
+
},
|
|
22
|
+
handler: (args) => {
|
|
23
|
+
const files = Array.isArray(args.files) ? args.files.map(String) : [];
|
|
24
|
+
const routes = fileToRoutes(files);
|
|
25
|
+
return jsonResult({ routes });
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/tools/routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAkB,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAoC,MAAM,eAAe,CAAC;AAE7E,MAAM,CAAC,MAAM,UAAU,GAAY;IACjC,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,+LAA+L;IACjM,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,iGAAiG;aAC/G;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;IACD,OAAO,EAAE,CAAC,IAA6B,EAAiB,EAAE;QACxD,MAAM,KAAK,GAAa,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,KAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,MAAM,MAAM,GAAgB,YAAY,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_scaffold_component` — generate the boilerplate for a new Weave component (the
|
|
3
|
+
* sibling-convention `.ts` + `.html` [+ style] trio), following the create-weave idiom. Pure:
|
|
4
|
+
* it RETURNS the files (path + content) rather than writing them, so the agent/editor stays in
|
|
5
|
+
* control of the filesystem (RFC 0006 §Unresolved #3 — no unsolicited writes).
|
|
6
|
+
*/
|
|
7
|
+
import { type McpTool } from '../jsonrpc.js';
|
|
8
|
+
/** One generated file. */
|
|
9
|
+
export interface GeneratedFile {
|
|
10
|
+
path: string;
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
/** Generate a component's files. `styleLang` of `'none'` omits the stylesheet. */
|
|
14
|
+
export declare function generateComponent(name: string, styleLang?: 'css' | 'scss' | 'none'): GeneratedFile[];
|
|
15
|
+
export declare const scaffoldComponentTool: McpTool;
|
|
16
|
+
//# sourceMappingURL=scaffold-component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold-component.d.ts","sourceRoot":"","sources":["../../src/tools/scaffold-component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,KAAK,OAAO,EAAsB,MAAM,eAAe,CAAC;AAE7E,0BAA0B;AAC1B,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AASD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,KAAK,GAAG,MAAM,GAAG,MAAc,GACzC,aAAa,EAAE,CAgCjB;AAED,eAAO,MAAM,qBAAqB,EAAE,OAsBnC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `weave_scaffold_component` — generate the boilerplate for a new Weave component (the
|
|
3
|
+
* sibling-convention `.ts` + `.html` [+ style] trio), following the create-weave idiom. Pure:
|
|
4
|
+
* it RETURNS the files (path + content) rather than writing them, so the agent/editor stays in
|
|
5
|
+
* control of the filesystem (RFC 0006 §Unresolved #3 — no unsolicited writes).
|
|
6
|
+
*/
|
|
7
|
+
import { jsonResult } from '../jsonrpc.js';
|
|
8
|
+
const kebab = (s) => s
|
|
9
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
10
|
+
.replace(/[\s_]+/g, '-')
|
|
11
|
+
.toLowerCase()
|
|
12
|
+
.replace(/[^a-z0-9-]/g, '');
|
|
13
|
+
/** Generate a component's files. `styleLang` of `'none'` omits the stylesheet. */
|
|
14
|
+
export function generateComponent(name, styleLang = 'css') {
|
|
15
|
+
const base = kebab(name) || 'component';
|
|
16
|
+
const files = [];
|
|
17
|
+
const styleImport = styleLang === 'none' ? '' : `\n// styles: ./${base}.${styleLang}`;
|
|
18
|
+
files.push({
|
|
19
|
+
path: `${base}/${base}.ts`,
|
|
20
|
+
content: `import { signal, type Signal } from '@weave-framework/runtime';\n\n` +
|
|
21
|
+
`export function setup(): { count: Signal<number>; inc: () => void } {\n` +
|
|
22
|
+
` const count: Signal<number> = signal(0);\n` +
|
|
23
|
+
` const inc = (): void => count.set((n) => n + 1);\n` +
|
|
24
|
+
` return { count, inc };\n` +
|
|
25
|
+
`}${styleImport}\n`,
|
|
26
|
+
});
|
|
27
|
+
files.push({
|
|
28
|
+
path: `${base}/${base}.html`,
|
|
29
|
+
content: `<section class="${base}">\n` +
|
|
30
|
+
` <button on:click={{ inc }}>clicked {{ count() }} times</button>\n` +
|
|
31
|
+
`</section>\n`,
|
|
32
|
+
});
|
|
33
|
+
if (styleLang !== 'none') {
|
|
34
|
+
files.push({
|
|
35
|
+
path: `${base}/${base}.${styleLang}`,
|
|
36
|
+
content: `.${base} {\n display: block;\n}\n`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
}
|
|
41
|
+
export const scaffoldComponentTool = {
|
|
42
|
+
name: 'weave_scaffold_component',
|
|
43
|
+
description: 'Generate the boilerplate files for a new Weave component (a .ts + .html [+ stylesheet], the sibling-convention trio). Returns the files (path + content) WITHOUT writing them — write them yourself.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
name: { type: 'string', description: 'Component name (PascalCase or kebab-case), e.g. "UserCard".' },
|
|
48
|
+
styleLang: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
enum: ['css', 'scss', 'none'],
|
|
51
|
+
description: 'Stylesheet language, or "none" to skip the stylesheet. Default "css".',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ['name'],
|
|
55
|
+
},
|
|
56
|
+
handler: (args) => {
|
|
57
|
+
const name = String(args.name ?? '');
|
|
58
|
+
const styleLang = args.styleLang === 'scss' || args.styleLang === 'none' ? args.styleLang : 'css';
|
|
59
|
+
return jsonResult({ files: generateComponent(name, styleLang) });
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=scaffold-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold-component.js","sourceRoot":"","sources":["../../src/tools/scaffold-component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAoC,MAAM,eAAe,CAAC;AAQ7E,MAAM,KAAK,GAAG,CAAC,CAAS,EAAU,EAAE,CAClC,CAAC;KACE,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;KACtC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;KACvB,WAAW,EAAE;KACb,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAEhC,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,YAAqC,KAAK;IAE1C,MAAM,IAAI,GAAW,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC;IAChD,MAAM,KAAK,GAAoB,EAAE,CAAC;IAElC,MAAM,WAAW,GAAW,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,IAAI,IAAI,SAAS,EAAE,CAAC;IAC9F,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,KAAK;QAC1B,OAAO,EACL,qEAAqE;YACrE,yEAAyE;YACzE,8CAA8C;YAC9C,sDAAsD;YACtD,4BAA4B;YAC5B,IAAI,WAAW,I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/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@weave-framework/mcp",
|
|
3
|
+
"version": "0.2.162",
|
|
4
|
+
"description": "Weave MCP server — exposes the Weave toolchain (compile/check/routes/scaffold) to AI agents & editors as Model Context Protocol tools. In-house JSON-RPC over stdio, zero third-party deps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"bin": {
|
|
11
|
+
"weave-mcp": "./bin/weave-mcp-dist.mjs"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"bin"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/weave-framework/weave.git",
|
|
29
|
+
"directory": "packages/mcp"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@weave-framework/compiler": "0.2.162",
|
|
36
|
+
"@weave-framework/check": "0.2.162",
|
|
37
|
+
"@weave-framework/router": "0.2.162"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT"
|
|
40
|
+
}
|