@openpresentation/mcp 0.0.1 → 0.29.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 +33 -1
- package/dist/bin.js +36 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-4FQTU7KN.js +71 -0
- package/dist/chunk-4FQTU7KN.js.map +1 -0
- package/dist/chunk-7STOTAET.js +882 -0
- package/dist/chunk-7STOTAET.js.map +1 -0
- package/dist/chunk-MX4ICVMM.js +33 -0
- package/dist/chunk-MX4ICVMM.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +58 -0
- package/dist/server.js +11 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.d.ts +16 -0
- package/dist/stdio.js +11 -0
- package/dist/stdio.js.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createOpfServer
|
|
3
|
+
} from "./chunk-4FQTU7KN.js";
|
|
4
|
+
|
|
5
|
+
// src/stdio.ts
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import { Reporter, measuringFonts, readDeckReport } from "@openpresentation/opf/internal/engine";
|
|
9
|
+
async function checkDeckText(raw, format, options) {
|
|
10
|
+
const measuring = await measuringFonts(readDeckReport(raw, { format, validate: false }).presentation, { reporter: new Reporter(), flags: true });
|
|
11
|
+
try {
|
|
12
|
+
const { presentation: _deck, format: _format, ...report } = readDeckReport(raw, { format, validate: measuring.fonts ? { ...options, fonts: measuring.fonts } : options });
|
|
13
|
+
if (measuring.estimated && report.checks.layout === "estimated") {
|
|
14
|
+
const named = measuring.estimated.details?.package ?? "@openpresentation/opf-render";
|
|
15
|
+
return { ...report, hint: `Layout was estimated: ${named} is not installed, so text was measured with core's portable estimate rather than the fonts opf convert draws with. To measure it, install it: npm install ${named}` };
|
|
16
|
+
}
|
|
17
|
+
return report;
|
|
18
|
+
} finally {
|
|
19
|
+
measuring.release();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function runStdio(host = {}) {
|
|
23
|
+
const opfVersion = host.opfVersion ?? createRequire(import.meta.url)("@openpresentation/opf/package.json").version;
|
|
24
|
+
const server = createOpfServer({ version: host.version ?? "0.29.0", opfVersion, checkText: checkDeckText });
|
|
25
|
+
process.stdin.once("close", () => void server.close());
|
|
26
|
+
await server.connect(new StdioServerTransport());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
checkDeckText,
|
|
31
|
+
runStdio
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=chunk-MX4ICVMM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stdio.ts"],"sourcesContent":["// `opf-mcp`: the OPF MCP server over stdio. A thin wrapper: the server definition is ./server.ts; this adds the transport and, because\n// it runs under Node, the measured layout check `opf validate` makes (the fonts of @openpresentation/opf-render when it is installed;\n// otherwise core's estimate, and the report's hint says so). Stdout carries the protocol and nothing else; diagnostics go to stderr.\nimport { createRequire } from \"node:module\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport type { ValidateOptions, ValidationReport } from \"@openpresentation/opf\";\nimport { Reporter, measuringFonts, readDeckReport } from \"@openpresentation/opf/internal/engine\";\nimport { type DeckFormat, createOpfServer } from \"./index.js\";\n\ndeclare const MCP_VERSION: string;\n\n/** The versions the server reports: this package's, and the core it runs on. */\nexport interface StdioHost {\n\tversion?: string;\n\topfVersion?: string;\n}\n\n/** Deck text checked as `opf validate` checks it: layout measured with the fonts `opf convert` draws with when opf-render is installed. */\nexport async function checkDeckText(raw: string, format: DeckFormat, options: ValidateOptions): Promise<ValidationReport> {\n\tconst measuring = await measuringFonts(readDeckReport(raw, { format, validate: false }).presentation, { reporter: new Reporter(), flags: true });\n\ttry {\n\t\tconst { presentation: _deck, format: _format, ...report } = readDeckReport(raw, { format, validate: measuring.fonts ? { ...options, fonts: measuring.fonts } : options });\n\t\tif (measuring.estimated && report.checks.layout === \"estimated\") {\n\t\t\tconst named = (measuring.estimated.details as { package?: string } | undefined)?.package ?? \"@openpresentation/opf-render\";\n\t\t\treturn { ...report, hint: `Layout was estimated: ${named} is not installed, so text was measured with core's portable estimate rather than the fonts opf convert draws with. To measure it, install it: npm install ${named}` } as ValidationReport;\n\t\t}\n\t\treturn report;\n\t} finally {\n\t\tmeasuring.release();\n\t}\n}\n\n/** Serve MCP on stdin and stdout until the client closes stdin. */\nexport async function runStdio(host: StdioHost = {}): Promise<void> {\n\tconst opfVersion = host.opfVersion ?? (createRequire(import.meta.url)(\"@openpresentation/opf/package.json\") as { version: string }).version;\n\tconst server = createOpfServer({ version: host.version ?? MCP_VERSION, opfVersion, checkText: checkDeckText });\n\t// The client closing stdin ends the session; with nothing left open the process exits on its own.\n\tprocess.stdin.once(\"close\", () => void server.close());\n\tawait server.connect(new StdioServerTransport());\n}\n"],"mappings":";;;;;AAGA,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AAErC,SAAS,UAAU,gBAAgB,sBAAsB;AAYzD,eAAsB,cAAc,KAAa,QAAoB,SAAqD;AACzH,QAAM,YAAY,MAAM,eAAe,eAAe,KAAK,EAAE,QAAQ,UAAU,MAAM,CAAC,EAAE,cAAc,EAAE,UAAU,IAAI,SAAS,GAAG,OAAO,KAAK,CAAC;AAC/I,MAAI;AACH,UAAM,EAAE,cAAc,OAAO,QAAQ,SAAS,GAAG,OAAO,IAAI,eAAe,KAAK,EAAE,QAAQ,UAAU,UAAU,QAAQ,EAAE,GAAG,SAAS,OAAO,UAAU,MAAM,IAAI,QAAQ,CAAC;AACxK,QAAI,UAAU,aAAa,OAAO,OAAO,WAAW,aAAa;AAChE,YAAM,QAAS,UAAU,UAAU,SAA8C,WAAW;AAC5F,aAAO,EAAE,GAAG,QAAQ,MAAM,yBAAyB,KAAK,8JAA8J,KAAK,GAAG;AAAA,IAC/N;AACA,WAAO;AAAA,EACR,UAAE;AACD,cAAU,QAAQ;AAAA,EACnB;AACD;AAGA,eAAsB,SAAS,OAAkB,CAAC,GAAkB;AACnE,QAAM,aAAa,KAAK,cAAe,cAAc,YAAY,GAAG,EAAE,oCAAoC,EAA0B;AACpI,QAAM,SAAS,gBAAgB,EAAE,SAAS,KAAK,WAAW,UAAa,YAAY,WAAW,cAAc,CAAC;AAE7G,UAAQ,MAAM,KAAK,SAAS,MAAM,KAAK,OAAO,MAAM,CAAC;AACrD,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AAChD;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { OpfMcpSources, OpfMcpOptions } from './server.js';
|
|
3
|
+
export { CheckText, DeckFormat, DocPage, ExamplePage, McpToolError, ResolvedSchema, createOpfMcpServer, resolveSchema } from './server.js';
|
|
4
|
+
import '@openpresentation/opf';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The documentation pages for people and agents who use OPF, by slug. Core bundles every top-level page of docs/; this list leaves
|
|
8
|
+
* out what is for the maintainers: handoffs, evidence, status and backlog notes, security and release runbooks, the compatibility
|
|
9
|
+
* matrix. A new page is listed here on purpose (the test checks every slug exists and that no dated or handoff page is listed).
|
|
10
|
+
*/
|
|
11
|
+
declare const DOC_SLUGS: readonly string[];
|
|
12
|
+
/** The bundled sources. Pass `{ ...defaultSources(), examples: [] }` to a host that must stay small. */
|
|
13
|
+
declare function defaultSources(): OpfMcpSources;
|
|
14
|
+
|
|
15
|
+
/** The server with the bundled docs, examples, skills and release notes (`sources` replaces any of them, for a host that must stay small). */
|
|
16
|
+
declare function createOpfServer(options: Omit<OpfMcpOptions, "sources"> & {
|
|
17
|
+
sources?: Partial<OpfMcpOptions["sources"]>;
|
|
18
|
+
}): McpServer;
|
|
19
|
+
|
|
20
|
+
export { DOC_SLUGS, OpfMcpOptions, OpfMcpSources, createOpfServer, defaultSources };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DOC_SLUGS,
|
|
3
|
+
createOpfServer,
|
|
4
|
+
defaultSources
|
|
5
|
+
} from "./chunk-4FQTU7KN.js";
|
|
6
|
+
import {
|
|
7
|
+
McpToolError,
|
|
8
|
+
createOpfMcpServer,
|
|
9
|
+
resolveSchema
|
|
10
|
+
} from "./chunk-7STOTAET.js";
|
|
11
|
+
export {
|
|
12
|
+
DOC_SLUGS,
|
|
13
|
+
McpToolError,
|
|
14
|
+
createOpfMcpServer,
|
|
15
|
+
createOpfServer,
|
|
16
|
+
defaultSources,
|
|
17
|
+
resolveSchema
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { ValidateOptions, ValidationReport } from '@openpresentation/opf';
|
|
3
|
+
|
|
4
|
+
type DeckFormat = "json" | "yaml" | "markdown";
|
|
5
|
+
/** A documentation page: its slug (the file name without `.md`), its first heading and its Markdown. */
|
|
6
|
+
interface DocPage {
|
|
7
|
+
slug: string;
|
|
8
|
+
title: string;
|
|
9
|
+
markdown: string;
|
|
10
|
+
}
|
|
11
|
+
/** An example deck: its slug (the file name without `.opf.json`), its folder under examples/ and the deck. */
|
|
12
|
+
interface ExamplePage {
|
|
13
|
+
slug: string;
|
|
14
|
+
category: string;
|
|
15
|
+
gallery?: string | null;
|
|
16
|
+
file: string;
|
|
17
|
+
deck: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** The data the server serves. `skills` maps a skill name to its files (`SKILL.md`, `references/...`), path to text. */
|
|
20
|
+
interface OpfMcpSources {
|
|
21
|
+
docs: readonly DocPage[];
|
|
22
|
+
examples: readonly ExamplePage[];
|
|
23
|
+
skills: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
24
|
+
/** The recent release notes, as text: `opf://docs/whats-new`. Left out when absent. */
|
|
25
|
+
whatsNew?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Checks deck text as `opf validate` does and returns the report. The default is edge-safe (layout estimated); `opf mcp` supplies the measured one. */
|
|
28
|
+
type CheckText = (raw: string, format: DeckFormat, options: ValidateOptions) => Promise<ValidationReport> | ValidationReport;
|
|
29
|
+
interface OpfMcpOptions {
|
|
30
|
+
/** The version the server reports (the CLI's). */
|
|
31
|
+
version: string;
|
|
32
|
+
/** The version of core the checks run on. */
|
|
33
|
+
opfVersion?: string;
|
|
34
|
+
sources: OpfMcpSources;
|
|
35
|
+
checkText?: CheckText;
|
|
36
|
+
}
|
|
37
|
+
/** A failure the tools report as `{ ok: false, code, error, ... }` with `isError`. */
|
|
38
|
+
declare class McpToolError extends Error {
|
|
39
|
+
readonly code: string;
|
|
40
|
+
readonly details: Record<string, unknown>;
|
|
41
|
+
constructor(message: string, code: string, details?: Record<string, unknown>);
|
|
42
|
+
}
|
|
43
|
+
interface ResolvedSchema {
|
|
44
|
+
name: string;
|
|
45
|
+
pointer: string;
|
|
46
|
+
id?: string;
|
|
47
|
+
schema: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A schema, or the part of one. `name` is a schema (`opf schemas` lists them) or a `$defs` name (`Chart`, found in the presentation
|
|
51
|
+
* schema first); `pointer` is a JSON Pointer into the schema, or a `$defs` name. Like `opf schema`, `$ref`s are left as written.
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveSchema(name?: string, pointer?: string, opfVersion?: string): ResolvedSchema;
|
|
54
|
+
/** Build the server. Connect it to a transport (`server.connect(...)`): stdio for `opf mcp`, Streamable HTTP for a hosted one. */
|
|
55
|
+
declare function createOpfMcpServer(options: OpfMcpOptions): McpServer;
|
|
56
|
+
|
|
57
|
+
export { McpToolError, createOpfMcpServer, resolveSchema };
|
|
58
|
+
export type { CheckText, DeckFormat, DocPage, ExamplePage, OpfMcpOptions, OpfMcpSources, ResolvedSchema };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/stdio.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ValidateOptions, ValidationReport } from '@openpresentation/opf';
|
|
2
|
+
import { DeckFormat } from './server.js';
|
|
3
|
+
import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
|
|
5
|
+
/** The versions the server reports: this package's, and the core it runs on. */
|
|
6
|
+
interface StdioHost {
|
|
7
|
+
version?: string;
|
|
8
|
+
opfVersion?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Deck text checked as `opf validate` checks it: layout measured with the fonts `opf convert` draws with when opf-render is installed. */
|
|
11
|
+
declare function checkDeckText(raw: string, format: DeckFormat, options: ValidateOptions): Promise<ValidationReport>;
|
|
12
|
+
/** Serve MCP on stdin and stdout until the client closes stdin. */
|
|
13
|
+
declare function runStdio(host?: StdioHost): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { checkDeckText, runStdio };
|
|
16
|
+
export type { StdioHost };
|
package/dist/stdio.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpresentation/mcp",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.29.0",
|
|
4
|
+
"description": "An MCP server for OPF: learn the format (docs, schemas, the default catalog, examples and agent skills as resources and tools), validate and convert decks. Runs locally on stdio (opf-mcp) or hosted on an edge runtime.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"author": "Open Presentation",
|
|
7
|
+
"homepage": "https://github.com/OpenPresentation/opf/blob/main/docs/mcp.md",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"opf",
|
|
10
|
+
"open-presentation-format",
|
|
11
|
+
"mcp",
|
|
12
|
+
"model-context-protocol",
|
|
13
|
+
"presentation",
|
|
14
|
+
"agents"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"bin": {
|
|
18
|
+
"opf-mcp": "./dist/bin.js"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./server": {
|
|
28
|
+
"types": "./dist/server.d.ts",
|
|
29
|
+
"default": "./dist/server.js"
|
|
30
|
+
},
|
|
31
|
+
"./stdio": {
|
|
32
|
+
"types": "./dist/stdio.d.ts",
|
|
33
|
+
"default": "./dist/stdio.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
39
|
+
"zod": "4.6.7",
|
|
40
|
+
"@openpresentation/opf": "^0.29.0",
|
|
41
|
+
"@openpresentation/gallery": "^0.29.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^24.13.4",
|
|
45
|
+
"tsup": "^9.0.0",
|
|
46
|
+
"typescript": "~5.9.3",
|
|
47
|
+
"workerd": "1.20261023.1",
|
|
48
|
+
"@openpresentation/cli": "0.29.0",
|
|
49
|
+
"@openpresentation/opf-render": "0.29.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@openpresentation/opf-render": "^0.29.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@openpresentation/opf-render": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"dist",
|
|
61
|
+
"README.md",
|
|
62
|
+
"LICENSE"
|
|
63
|
+
],
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=22"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "git+https://github.com/OpenPresentation/opf.git",
|
|
73
|
+
"directory": "packages/mcp"
|
|
74
|
+
},
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/OpenPresentation/opf/issues"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build:deps": "pnpm --filter \"@openpresentation/mcp^...\" --fail-if-no-match run build",
|
|
80
|
+
"build": "node ../../scripts/reuse-build.mjs check || (tsup && node ../../scripts/reuse-build.mjs stamp)",
|
|
81
|
+
"typecheck": "pnpm run build:deps && node ../../scripts/typecheck.mjs --noEmit",
|
|
82
|
+
"clean": "rm -rf dist",
|
|
83
|
+
"test": "pnpm run build:deps && pnpm run build && node ../../scripts/run-tests.mjs"
|
|
84
|
+
},
|
|
85
|
+
"gitHead": "464e10d3c15647b0e43326ac7e6761e34789991a"
|
|
8
86
|
}
|