@silverpoint/mcp 0.0.0-stage → 0.8.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/LICENSE +21 -0
- package/README.md +96 -2
- package/agent-catalog.json +10966 -0
- package/dist/bin.js +5 -0
- package/dist/chunk-NUDC553W.js +12059 -0
- package/dist/http.d.ts +7 -0
- package/dist/http.js +71 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/server-BXBjhMwX.d.ts +221 -0
- package/package.json +53 -3
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { S as ServerOptions } from './server-BXBjhMwX.js';
|
|
2
|
+
import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
|
|
4
|
+
declare const BODY_LIMIT: number;
|
|
5
|
+
declare function handler(request: Request, options?: ServerOptions): Promise<Response>;
|
|
6
|
+
|
|
7
|
+
export { BODY_LIMIT, handler };
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { LIMITS, createServer } from './chunk-NUDC553W.js';
|
|
2
|
+
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
3
|
+
|
|
4
|
+
var BODY_LIMIT = LIMITS.body;
|
|
5
|
+
var CORS = {
|
|
6
|
+
"access-control-allow-origin": "*",
|
|
7
|
+
"access-control-allow-methods": "POST, OPTIONS",
|
|
8
|
+
"access-control-allow-headers": "content-type, accept, mcp-protocol-version, mcp-session-id, last-event-id",
|
|
9
|
+
"access-control-expose-headers": "mcp-session-id, mcp-protocol-version",
|
|
10
|
+
"access-control-max-age": "86400"
|
|
11
|
+
};
|
|
12
|
+
function withCors(response) {
|
|
13
|
+
const headers = new Headers(response.headers);
|
|
14
|
+
for (const [name, value] of Object.entries(CORS)) headers.set(name, value);
|
|
15
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
16
|
+
}
|
|
17
|
+
function rpcError(status, code, message, extra = {}) {
|
|
18
|
+
return new Response(JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }), {
|
|
19
|
+
status,
|
|
20
|
+
headers: { "content-type": "application/json", ...CORS, ...extra }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function boundedText(request) {
|
|
24
|
+
if (!request.body) return "";
|
|
25
|
+
const reader = request.body.getReader();
|
|
26
|
+
const chunks = [];
|
|
27
|
+
let size = 0;
|
|
28
|
+
for (; ; ) {
|
|
29
|
+
const { done, value } = await reader.read();
|
|
30
|
+
if (done) break;
|
|
31
|
+
size += value.byteLength;
|
|
32
|
+
if (size > BODY_LIMIT) {
|
|
33
|
+
await reader.cancel();
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
chunks.push(value);
|
|
37
|
+
}
|
|
38
|
+
const bytes = new Uint8Array(size);
|
|
39
|
+
let offset = 0;
|
|
40
|
+
for (const chunk of chunks) {
|
|
41
|
+
bytes.set(chunk, offset);
|
|
42
|
+
offset += chunk.byteLength;
|
|
43
|
+
}
|
|
44
|
+
return new TextDecoder().decode(bytes);
|
|
45
|
+
}
|
|
46
|
+
var TOO_LARGE = `The request body exceeds ${BODY_LIMIT} bytes.`;
|
|
47
|
+
async function handler(request, options = {}) {
|
|
48
|
+
if (request.method === "OPTIONS") return new Response(null, { status: 204, headers: CORS });
|
|
49
|
+
if (request.method !== "POST") return rpcError(405, -32e3, "Method not allowed: this server is stateless, POST only.", { allow: "POST, OPTIONS" });
|
|
50
|
+
const length = Number(request.headers.get("content-length") ?? Number.NaN);
|
|
51
|
+
if (length > BODY_LIMIT) return rpcError(413, -32e3, TOO_LARGE);
|
|
52
|
+
const text = await boundedText(request);
|
|
53
|
+
if (text === void 0) return rpcError(413, -32e3, TOO_LARGE);
|
|
54
|
+
let parsedBody;
|
|
55
|
+
try {
|
|
56
|
+
parsedBody = JSON.parse(text);
|
|
57
|
+
} catch {
|
|
58
|
+
return rpcError(400, -32700, "Parse error: the body is not JSON.");
|
|
59
|
+
}
|
|
60
|
+
const server = createServer(options);
|
|
61
|
+
const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: void 0, enableJsonResponse: true });
|
|
62
|
+
try {
|
|
63
|
+
await server.connect(transport);
|
|
64
|
+
const forwarded = new Request(request.url, { method: "POST", headers: request.headers });
|
|
65
|
+
return withCors(await transport.handleRequest(forwarded, { parsedBody }));
|
|
66
|
+
} finally {
|
|
67
|
+
await server.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { BODY_LIMIT, handler };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { A as AgentCatalog } from './server-BXBjhMwX.js';
|
|
2
|
+
export { a as AdapterFramework, B as Binding, C as ChartEntry, b as ComponentEntry, D as DataField, c as DataShape, d as DataSpec, e as Diagnostic, F as Family, f as Framework, G as Ground, I as Imports, g as Intent, N as Names, P as PropEntry, R as RecommendRule, h as ReflexCatalog, i as ReflexProp, S as ServerOptions, j as createServer } from './server-BXBjhMwX.js';
|
|
3
|
+
import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
|
|
5
|
+
declare const AGENT_CATALOG: AgentCatalog;
|
|
6
|
+
|
|
7
|
+
export { AGENT_CATALOG, AgentCatalog };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AGENT_CATALOG, createServer } from './chunk-NUDC553W.js';
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The agent catalog (feature-005, Data Model §2.28..§2.30): the public API described for agents,
|
|
5
|
+
* generated by `tools/agent-catalog` from the published types, never typed by hand (REQ-530).
|
|
6
|
+
*/
|
|
7
|
+
type Framework = 'react' | 'vue' | 'angular' | 'reflex';
|
|
8
|
+
/** The three frameworks with a component layer of their own (no Reflex binding: it wraps React). */
|
|
9
|
+
type AdapterFramework = Exclude<Framework, 'reflex'>;
|
|
10
|
+
type Names = Readonly<Record<Framework, string>>;
|
|
11
|
+
type Imports = Readonly<Record<Framework, string>>;
|
|
12
|
+
/** What a chart's rows hold (API delta §3). */
|
|
13
|
+
type DataShape = 'series' | 'categories' | 'parts' | 'matrix' | 'hierarchy' | 'links' | 'points' | 'distribution' | 'intervals' | 'events' | 'single' | 'field';
|
|
14
|
+
/** What the reader is asked to see (API delta §3). */
|
|
15
|
+
type Intent = 'trend' | 'compare' | 'rank' | 'part-to-whole' | 'distribution' | 'correlation' | 'flow' | 'hierarchy' | 'change' | 'uncertainty' | 'progress' | 'schedule' | 'kpi' | 'network';
|
|
16
|
+
/**
|
|
17
|
+
* The chart families, the slugs of the nine the official site and `reflex-silverpoint-react`
|
|
18
|
+
* already show (Data Model §2.29, fixed at T-227).
|
|
19
|
+
*/
|
|
20
|
+
type Family = 'lines' | 'bars' | 'areas' | 'points-grids' | 'flows' | 'radial' | 'distributions-comparisons' | 'hierarchies-dimensions' | 'fields-networks';
|
|
21
|
+
interface PropEntry {
|
|
22
|
+
/** camelCase, as the types. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** snake_case, from the Reflex catalog; absent when Reflex lacks it. */
|
|
25
|
+
readonly reflex?: string;
|
|
26
|
+
readonly type: string;
|
|
27
|
+
readonly optional: boolean;
|
|
28
|
+
/** From API Spec §5.1, the core's own fallback literal, or the JSDoc. */
|
|
29
|
+
readonly default?: string;
|
|
30
|
+
readonly doc: string;
|
|
31
|
+
}
|
|
32
|
+
interface DataField {
|
|
33
|
+
/** What the field means to the chart: `x`, `value`, `source`… */
|
|
34
|
+
readonly role: string;
|
|
35
|
+
/** The accessor prop that names the field (`xKey`, `keys`…). */
|
|
36
|
+
readonly prop: string;
|
|
37
|
+
/** `array` for a field holding a list (a sparkline's points, a heatmap row's values). */
|
|
38
|
+
readonly type: 'string' | 'number' | 'date' | 'array';
|
|
39
|
+
readonly required: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface DataSpec {
|
|
42
|
+
readonly shape: DataShape;
|
|
43
|
+
readonly fields: readonly DataField[];
|
|
44
|
+
}
|
|
45
|
+
interface ChartEntry {
|
|
46
|
+
readonly slug: string;
|
|
47
|
+
readonly names: Names;
|
|
48
|
+
readonly imports: Imports;
|
|
49
|
+
readonly family: Family;
|
|
50
|
+
readonly summary: string;
|
|
51
|
+
readonly data: DataSpec;
|
|
52
|
+
readonly intents: readonly Intent[];
|
|
53
|
+
/** Own props only; the shared ones are in `common.chart`. */
|
|
54
|
+
readonly props: readonly PropEntry[];
|
|
55
|
+
/** The export holding the demo rows; absent when the chart draws from its props alone. */
|
|
56
|
+
readonly demo?: string;
|
|
57
|
+
/** The demo's accessor props, which name its non-default fields. */
|
|
58
|
+
readonly demoKeys?: Readonly<Record<string, unknown>>;
|
|
59
|
+
/** The demo's first rows: the shape of the data, by example, read through `demoKeys`. */
|
|
60
|
+
readonly demoSample?: readonly unknown[];
|
|
61
|
+
/** `rootId` + `onRootChange` (REQ-439). */
|
|
62
|
+
readonly drillable?: boolean;
|
|
63
|
+
/** Present when the Reflex catalog wraps another silverpoint version (REQ-556). */
|
|
64
|
+
readonly stale?: string;
|
|
65
|
+
}
|
|
66
|
+
/** How a component's value or open state is bound, per framework. */
|
|
67
|
+
interface Binding {
|
|
68
|
+
readonly value?: Readonly<Record<AdapterFramework, string>>;
|
|
69
|
+
readonly open?: Readonly<Record<AdapterFramework, string>>;
|
|
70
|
+
}
|
|
71
|
+
interface ComponentEntry {
|
|
72
|
+
readonly slug: string;
|
|
73
|
+
readonly names: Names;
|
|
74
|
+
readonly imports: Imports;
|
|
75
|
+
readonly family: 'ui' | 'composed' | 'overlay';
|
|
76
|
+
readonly group: string;
|
|
77
|
+
readonly summary: string;
|
|
78
|
+
readonly props: readonly PropEntry[];
|
|
79
|
+
readonly binding?: Binding;
|
|
80
|
+
/** Event names per framework: React handler props, Vue emits, Angular outputs. */
|
|
81
|
+
readonly events: Readonly<Record<AdapterFramework, readonly string[]>>;
|
|
82
|
+
/** Named content per framework: React node props, Vue slots, Angular templates and projections. */
|
|
83
|
+
readonly slots: Readonly<Record<AdapterFramework, readonly string[]>>;
|
|
84
|
+
/** Declared states (Data Model §5). */
|
|
85
|
+
readonly states: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* The first state's demo props (`UI_DEMOS`, `id` left out): own props plus `value` for a bound
|
|
88
|
+
* value, `content` for the text it holds and `trigger` for an overlay's trigger text.
|
|
89
|
+
*/
|
|
90
|
+
readonly demo: Readonly<Record<string, unknown>>;
|
|
91
|
+
readonly stale?: string;
|
|
92
|
+
}
|
|
93
|
+
interface Diagnostic {
|
|
94
|
+
readonly code: string;
|
|
95
|
+
readonly severity: 'warn' | 'error';
|
|
96
|
+
readonly req: string;
|
|
97
|
+
readonly what: string;
|
|
98
|
+
readonly todo: string;
|
|
99
|
+
}
|
|
100
|
+
interface Ground {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly substrates: readonly string[];
|
|
103
|
+
readonly summary: string;
|
|
104
|
+
}
|
|
105
|
+
/** One row of the recommender's table (Data Model §2.31, DD-046). */
|
|
106
|
+
interface RecommendRule {
|
|
107
|
+
readonly shape: DataShape;
|
|
108
|
+
readonly intent: Intent;
|
|
109
|
+
readonly charts: readonly {
|
|
110
|
+
readonly slug: string;
|
|
111
|
+
readonly score: number;
|
|
112
|
+
readonly reason: string;
|
|
113
|
+
}[];
|
|
114
|
+
readonly adjust?: readonly {
|
|
115
|
+
readonly when: 'rows>' | 'rows<' | 'values>';
|
|
116
|
+
readonly n: number;
|
|
117
|
+
readonly slug: string;
|
|
118
|
+
readonly delta: number;
|
|
119
|
+
readonly reason: string;
|
|
120
|
+
}[];
|
|
121
|
+
}
|
|
122
|
+
interface AgentCatalog {
|
|
123
|
+
readonly schema: 1;
|
|
124
|
+
/** The library version described (REQ-534). */
|
|
125
|
+
readonly version: string;
|
|
126
|
+
readonly reflex: {
|
|
127
|
+
readonly version: string;
|
|
128
|
+
readonly wraps: string;
|
|
129
|
+
readonly stale: boolean;
|
|
130
|
+
};
|
|
131
|
+
readonly frameworks: readonly Framework[];
|
|
132
|
+
readonly families: readonly {
|
|
133
|
+
readonly slug: Family;
|
|
134
|
+
readonly title: string;
|
|
135
|
+
}[];
|
|
136
|
+
readonly common: {
|
|
137
|
+
readonly chart: readonly PropEntry[];
|
|
138
|
+
readonly ui: readonly PropEntry[];
|
|
139
|
+
};
|
|
140
|
+
readonly charts: readonly ChartEntry[];
|
|
141
|
+
readonly components: readonly ComponentEntry[];
|
|
142
|
+
readonly dashboard: {
|
|
143
|
+
readonly props: readonly PropEntry[];
|
|
144
|
+
readonly layout: readonly PropEntry[];
|
|
145
|
+
readonly cell: readonly PropEntry[];
|
|
146
|
+
readonly names: Names;
|
|
147
|
+
readonly imports: Imports;
|
|
148
|
+
};
|
|
149
|
+
readonly grounds: readonly Ground[];
|
|
150
|
+
readonly palettes: {
|
|
151
|
+
readonly fields: readonly PropEntry[];
|
|
152
|
+
readonly presets: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
153
|
+
};
|
|
154
|
+
readonly timeline: {
|
|
155
|
+
readonly props: readonly PropEntry[];
|
|
156
|
+
readonly names: Names;
|
|
157
|
+
readonly imports: Imports;
|
|
158
|
+
readonly peer: string;
|
|
159
|
+
};
|
|
160
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
161
|
+
/** The recommender's table (DD-046): `recommend_chart` reads it, never a model. */
|
|
162
|
+
readonly recommend: readonly RecommendRule[];
|
|
163
|
+
readonly stylesheets: {
|
|
164
|
+
readonly always: readonly string[];
|
|
165
|
+
readonly ui: readonly string[];
|
|
166
|
+
readonly timeline: readonly string[];
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** `reflex-catalog.json`, exported by `reflex-silverpoint-react` (Data Model §2.30, DD-049). */
|
|
170
|
+
interface ReflexCatalog {
|
|
171
|
+
readonly schema: 1;
|
|
172
|
+
readonly package: 'reflex-silverpoint-react';
|
|
173
|
+
/** The wheel's version. */
|
|
174
|
+
readonly version: string;
|
|
175
|
+
/** `SILVERPOINT_VERSION`: the silverpoint version that release wraps. */
|
|
176
|
+
readonly wraps: string;
|
|
177
|
+
/** How the file was produced, when not by the package's own export (the interim pin of T-231). */
|
|
178
|
+
readonly derived?: string;
|
|
179
|
+
/** The props every chart and every component share, with their Python names. */
|
|
180
|
+
readonly common?: {
|
|
181
|
+
readonly chart: readonly ReflexProp[];
|
|
182
|
+
readonly ui: readonly ReflexProp[];
|
|
183
|
+
};
|
|
184
|
+
readonly charts: readonly {
|
|
185
|
+
readonly slug: string;
|
|
186
|
+
readonly builder: string;
|
|
187
|
+
readonly cls: string;
|
|
188
|
+
readonly family: string;
|
|
189
|
+
readonly summary?: string;
|
|
190
|
+
readonly props: readonly ReflexProp[];
|
|
191
|
+
}[];
|
|
192
|
+
readonly components: readonly {
|
|
193
|
+
readonly slug: string;
|
|
194
|
+
readonly builder: string;
|
|
195
|
+
readonly cls: string;
|
|
196
|
+
readonly props: readonly ReflexProp[];
|
|
197
|
+
readonly positional: readonly string[];
|
|
198
|
+
readonly deprecated: Readonly<Record<string, string>>;
|
|
199
|
+
}[];
|
|
200
|
+
readonly helpers: readonly string[];
|
|
201
|
+
}
|
|
202
|
+
interface ReflexProp {
|
|
203
|
+
readonly name: string;
|
|
204
|
+
readonly js: string;
|
|
205
|
+
readonly type: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* `createServer` (API delta §1, REQ-538): an `McpServer` holding every tool, resource and prompt of
|
|
210
|
+
* the agent catalog. Each tool is a pure function of its input and the catalog (Art. 4); every
|
|
211
|
+
* result carries the catalog's version (REQ-550); a `ToolError` becomes a tool error the client
|
|
212
|
+
* reads as data (REQ-549).
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
interface ServerOptions {
|
|
216
|
+
/** The catalog to serve; the one this package ships by default. */
|
|
217
|
+
readonly catalog?: AgentCatalog;
|
|
218
|
+
}
|
|
219
|
+
declare function createServer(options?: ServerOptions): McpServer;
|
|
220
|
+
|
|
221
|
+
export { type AgentCatalog as A, type Binding as B, type ChartEntry as C, type DataField as D, type Family as F, type Ground as G, type Imports as I, type Names as N, type PropEntry as P, type RecommendRule as R, type ServerOptions as S, type AdapterFramework as a, type ComponentEntry as b, type DataShape as c, type DataSpec as d, type Diagnostic as e, type Framework as f, type Intent as g, type ReflexCatalog as h, type ReflexProp as i, createServer as j };
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silverpoint/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "An MCP server for silverpoint: the agent catalog as tools and resources, a chart recommender, code generation, prop validation and the canonical render.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"bin": {
|
|
12
|
+
"silverpoint-mcp": "./dist/bin.js"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"@silverpoint/source": "./src/index.ts",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./http": {
|
|
22
|
+
"@silverpoint/source": "./src/http.ts",
|
|
23
|
+
"types": "./dist/http.d.ts",
|
|
24
|
+
"import": "./dist/http.js",
|
|
25
|
+
"default": "./dist/http.js"
|
|
26
|
+
},
|
|
27
|
+
"./agent-catalog.json": "./agent-catalog.json",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"agent-catalog.json"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/ecrespo/silverpoint.git",
|
|
37
|
+
"directory": "packages/mcp"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": true
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
45
|
+
"@silverpoint/core": "0.8.0",
|
|
46
|
+
"@silverpoint/grounds": "0.8.0",
|
|
47
|
+
"zod": "^4.6.7"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"tsup": "^8.5.1"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"typecheck": "tsc -p tsconfig.json"
|
|
55
|
+
}
|
|
6
56
|
}
|