@agntn/tools 0.1.0 → 0.1.1

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/dist/mcp.d.mts CHANGED
@@ -4,6 +4,10 @@ export interface McpServerInfo {
4
4
  /** Server name, also used in the unknown-tool message. */
5
5
  readonly name: string;
6
6
  readonly version: string;
7
+ /** Display name for clients that show one, such as `Forges`. */
8
+ readonly title?: string;
9
+ /** Project home a client can link to. */
10
+ readonly websiteUrl?: string;
7
11
  }
8
12
  /**
9
13
  * Maps a tool's title and declared effect to MCP annotations. Claude Code reads its label here.
@@ -38,7 +42,7 @@ export declare function errorResult(...lines: readonly string[]): CallToolResult
38
42
  * clients that see structured output prefer it over `content` and would hide
39
43
  * the readable answer. Every fact a follow-up call needs belongs in the text.
40
44
  *
41
- * @param info - Server name and version.
45
+ * @param info - Server name, version and optional title and website, sent to the client as given.
42
46
  * @param tools - Tools to serve.
43
47
  * @returns {Server} Unconnected MCP server.
44
48
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp.ts"],"mappings":";;iBAoBiB;;WAEN;WACA;;;;;;;;wBASK,gBAAgB,MAAM,iBAAiB;;;;;;;;;;;;wBAqBvC,eAAe,2BAA2B;;;;;;;;;;;;;;;;;;;wBAsB1C,gBAAgB,MAAM,eAAe,gBAAgB,mBAAmB"}
1
+ {"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp.ts"],"mappings":";;iBAoBiB;;WAEN;WACA;;WAEA;;WAEA;;;;;;;;wBASK,gBAAgB,MAAM,iBAAiB;;;;;;;;;;;;wBAqBvC,eAAe,2BAA2B;;;;;;;;;;;;;;;;;;;wBAsB1C,gBAAgB,MAAM,eAAe,gBAAgB,mBAAmB"}
package/dist/mcp.mjs CHANGED
@@ -20,9 +20,12 @@ function errorResult(...lines) {
20
20
  }
21
21
  function createMcpServer(info, tools) {
22
22
  const byName = indexTools(tools);
23
+ const { name, version, title, websiteUrl } = info;
23
24
  const server = new Server({
24
- name: info.name,
25
- version: info.version
25
+ name,
26
+ version,
27
+ title,
28
+ websiteUrl
26
29
  }, { capabilities: { tools: {} } });
27
30
  server.setRequestHandler("tools/list", () => ({ tools: tools.map((tool) => ({
28
31
  name: tool.name,
@@ -33,7 +36,7 @@ function createMcpServer(info, tools) {
33
36
  })) }));
34
37
  server.setRequestHandler("tools/call", async (request, ctx) => {
35
38
  const tool = byName.get(request.params.name);
36
- if (!tool) return errorResult(`Unknown ${info.name} tool: ${JSON.stringify(request.params.name)}`);
39
+ if (!tool) return errorResult(`Unknown ${name} tool: ${JSON.stringify(request.params.name)}`);
37
40
  try {
38
41
  const result = await invokeTool(tool, request.params.arguments ?? {}, { signal: ctx.mcpReq.signal });
39
42
  return {
package/dist/mcp.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.mjs","names":[],"sources":["../src/mcp.ts"],"sourcesContent":["/**\n * MCP adapter: serves {@link ToolDefinition}s from an unconnected MCP server.\n */\n\nimport {\n Server,\n type CallToolResult,\n type Tool,\n type ToolAnnotations,\n} from \"@modelcontextprotocol/server\";\n\nimport {\n indexTools,\n invokeTool,\n sanitizeLine,\n ToolInputError,\n wireSchema,\n type ToolDefinition,\n} from \"./index.ts\";\n\nexport interface McpServerInfo {\n /** Server name, also used in the unknown-tool message. */\n readonly name: string;\n readonly version: string;\n}\n\n/**\n * Maps a tool's title and declared effect to MCP annotations. Claude Code reads its label here.\n *\n * @param tool - Tool to describe.\n * @returns {ToolAnnotations} Title and hints for the MCP client.\n */\nexport function toolAnnotations(tool: ToolDefinition): ToolAnnotations {\n return {\n title: tool.title,\n readOnlyHint: tool.effect === \"read\",\n destructiveHint: tool.effect === \"destructive\",\n idempotentHint: tool.idempotent ?? tool.effect === \"read\",\n openWorldHint: tool.openWorld ?? false,\n };\n}\n\n/**\n * Error result with every line-forging character replaced.\n *\n * The messages echo client-controlled values (a tool name, an argument) and\n * downstream error text, so they pass through here on every branch. Each line\n * is cleaned on its own, so only the breaks between the lines passed in\n * survive; a newline inside one line becomes a space.\n *\n * @param lines - Error lines.\n * @returns {CallToolResult} MCP error result.\n */\nexport function errorResult(...lines: readonly string[]): CallToolResult {\n return { content: [{ type: \"text\", text: lines.map(sanitizeLine).join(\"\\n\") }], isError: true };\n}\n\n/**\n * Creates an unconnected MCP server exposing the tools.\n *\n * Built on the low-level `Server` of MCP SDK v2, which the SDK marks\n * `@deprecated`, not on `McpServer`. `McpServer.registerTool` in 2.2.0 would\n * take the schema, but it answers `toString`, `constructor` and `__proto__` as\n * \"Tool toString disabled\" (a lookup that reaches `Object.prototype`), echoes a\n * raw tool name with newlines and escapes into its error, joins validation\n * failures into one line and passes a thrown message through unsanitized.\n *\n * `details` never reaches the client and `structuredContent` is never set:\n * clients that see structured output prefer it over `content` and would hide\n * the readable answer. Every fact a follow-up call needs belongs in the text.\n *\n * @param info - Server name and version.\n * @param tools - Tools to serve.\n * @returns {Server} Unconnected MCP server.\n */\nexport function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server {\n const byName = indexTools(tools);\n const server = new Server(\n { name: info.name, version: info.version },\n { capabilities: { tools: {} } },\n );\n\n server.setRequestHandler(\"tools/list\", () => ({\n tools: tools.map((tool): Tool => ({\n name: tool.name,\n title: tool.title,\n description: tool.description,\n inputSchema: wireSchema(tool) as Tool[\"inputSchema\"],\n annotations: toolAnnotations(tool),\n })),\n }));\n\n server.setRequestHandler(\"tools/call\", async (request, ctx) => {\n const tool = byName.get(request.params.name);\n if (!tool) {\n return errorResult(`Unknown ${info.name} tool: ${JSON.stringify(request.params.name)}`);\n }\n\n try {\n const result = await invokeTool(tool, request.params.arguments ?? {}, {\n signal: ctx.mcpReq.signal,\n });\n return {\n content: result.content,\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n } catch (error) {\n if (error instanceof ToolInputError) return errorResult(...error.lines);\n return errorResult(\n `${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n });\n\n return server;\n}\n"],"mappings":";;;;;;;;;CAgCA;AACE;AAEE,SAAA,YAAmB,GAAA,OAAA;CACnB,OAAA;EACA,SAAA,CAAA;GACA,MAAA;GACF,MAAA,MAAA,IAAA,YAAA,CAAA,CAAA,KAAA,IAAA;EACF,CAAA;;;;;;;;;;;EAaA,MAAA,KAAgB;EACd,OAAO,KAAA;EAAE,aAAU,KAAA;EAAE,aAAM,WAAA,IAAA;EAAQ,aAAY,gBAAgB,IAAE;CAAW,EAAC,EAAA,EAAA;CAAG,OAAA,kBAAS,cAAA,OAAA,SAAA,QAAA;EAAK,MAAA,OAAA,OAAA,IAAA,QAAA,OAAA,IAAA;EAChG,IAAA,CAAA,MAAA,OAAA,YAAA,WAAA,KAAA,KAAA,SAAA,KAAA,UAAA,QAAA,OAAA,IAAA,GAAA"}
1
+ {"version":3,"file":"mcp.mjs","names":[],"sources":["../src/mcp.ts"],"sourcesContent":["/**\n * MCP adapter: serves {@link ToolDefinition}s from an unconnected MCP server.\n */\n\nimport {\n Server,\n type CallToolResult,\n type Tool,\n type ToolAnnotations,\n} from \"@modelcontextprotocol/server\";\n\nimport {\n indexTools,\n invokeTool,\n sanitizeLine,\n ToolInputError,\n wireSchema,\n type ToolDefinition,\n} from \"./index.ts\";\n\nexport interface McpServerInfo {\n /** Server name, also used in the unknown-tool message. */\n readonly name: string;\n readonly version: string;\n /** Display name for clients that show one, such as `Forges`. */\n readonly title?: string;\n /** Project home a client can link to. */\n readonly websiteUrl?: string;\n}\n\n/**\n * Maps a tool's title and declared effect to MCP annotations. Claude Code reads its label here.\n *\n * @param tool - Tool to describe.\n * @returns {ToolAnnotations} Title and hints for the MCP client.\n */\nexport function toolAnnotations(tool: ToolDefinition): ToolAnnotations {\n return {\n title: tool.title,\n readOnlyHint: tool.effect === \"read\",\n destructiveHint: tool.effect === \"destructive\",\n idempotentHint: tool.idempotent ?? tool.effect === \"read\",\n openWorldHint: tool.openWorld ?? false,\n };\n}\n\n/**\n * Error result with every line-forging character replaced.\n *\n * The messages echo client-controlled values (a tool name, an argument) and\n * downstream error text, so they pass through here on every branch. Each line\n * is cleaned on its own, so only the breaks between the lines passed in\n * survive; a newline inside one line becomes a space.\n *\n * @param lines - Error lines.\n * @returns {CallToolResult} MCP error result.\n */\nexport function errorResult(...lines: readonly string[]): CallToolResult {\n return { content: [{ type: \"text\", text: lines.map(sanitizeLine).join(\"\\n\") }], isError: true };\n}\n\n/**\n * Creates an unconnected MCP server exposing the tools.\n *\n * Built on the low-level `Server` of MCP SDK v2, which the SDK marks\n * `@deprecated`, not on `McpServer`. `McpServer.registerTool` in 2.2.0 would\n * take the schema, but it answers `toString`, `constructor` and `__proto__` as\n * \"Tool toString disabled\" (a lookup that reaches `Object.prototype`), echoes a\n * raw tool name with newlines and escapes into its error, joins validation\n * failures into one line and passes a thrown message through unsanitized.\n *\n * `details` never reaches the client and `structuredContent` is never set:\n * clients that see structured output prefer it over `content` and would hide\n * the readable answer. Every fact a follow-up call needs belongs in the text.\n *\n * @param info - Server name, version and optional title and website, sent to the client as given.\n * @param tools - Tools to serve.\n * @returns {Server} Unconnected MCP server.\n */\nexport function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server {\n const byName = indexTools(tools);\n const { name, version, title, websiteUrl } = info;\n const server = new Server({ name, version, title, websiteUrl }, { capabilities: { tools: {} } });\n\n server.setRequestHandler(\"tools/list\", () => ({\n tools: tools.map((tool): Tool => ({\n name: tool.name,\n title: tool.title,\n description: tool.description,\n inputSchema: wireSchema(tool) as Tool[\"inputSchema\"],\n annotations: toolAnnotations(tool),\n })),\n }));\n\n server.setRequestHandler(\"tools/call\", async (request, ctx) => {\n const tool = byName.get(request.params.name);\n if (!tool) {\n return errorResult(`Unknown ${name} tool: ${JSON.stringify(request.params.name)}`);\n }\n\n try {\n const result = await invokeTool(tool, request.params.arguments ?? {}, {\n signal: ctx.mcpReq.signal,\n });\n return {\n content: result.content,\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n } catch (error) {\n if (error instanceof ToolInputError) return errorResult(...error.lines);\n return errorResult(\n `${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n });\n\n return server;\n}\n"],"mappings":";;;;;;;;;CAoCA;AACE;AAEE,SAAA,YAAmB,GAAA,OAAA;CACnB,OAAA;EACA,SAAA,CAAA;GACA,MAAA;GACF,MAAA,MAAA,IAAA,YAAA,CAAA,CAAA,KAAA,IAAA;EACF,CAAA;;;;;;;;;;;EAaA;CACE,GAAA,EAAA,cAAO,EAAA,OAAA,CAAA,EAAA,EAAA,CAAA;CAAE,OAAA,kBAAU,qBAAA,EAAA,OAAA,MAAA,KAAA,UAAA;EAAE,MAAA,KAAM;EAAQ,OAAM,KAAA;EAAmC,aAAC,KAAA;EAAG,aAAS,WAAA,IAAA;EAAK,aAAA,gBAAA,IAAA;CAChG,EAAA,EAAA,EAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agntn/tools",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "One tool definition for MCP, Pi, OMP and the AI SDK",
5
5
  "homepage": "https://github.com/agntn/tools#readme",
6
6
  "bugs": "https://github.com/agntn/tools/issues",
@@ -46,12 +46,12 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@agntn/ox": "0.1.0",
49
- "@earendil-works/pi-coding-agent": "0.84.2",
49
+ "@earendil-works/pi-coding-agent": "1.0.1",
50
50
  "@modelcontextprotocol/client": "2.2.0",
51
51
  "@modelcontextprotocol/server": "2.2.0",
52
52
  "@oh-my-pi/pi-coding-agent": "18.0.0",
53
53
  "@types/node": "26.2.0",
54
- "ai": "7.0.126",
54
+ "ai": "7.0.127",
55
55
  "changelogen": "0.6.2",
56
56
  "obuild": "0.4.43",
57
57
  "typebox": "1.3.34",
@@ -60,7 +60,7 @@
60
60
  "vite-plus": "1.0.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "@earendil-works/pi-coding-agent": ">=0.84.2 <1",
63
+ "@earendil-works/pi-coding-agent": ">=0.84.2 <2",
64
64
  "@modelcontextprotocol/server": ">=2.2.0 <3",
65
65
  "@oh-my-pi/pi-coding-agent": ">=18.0.0 <19",
66
66
  "ai": ">=7.0.0 <8"
@@ -87,8 +87,9 @@
87
87
  "lint": "vp lint && vp fmt --check",
88
88
  "lint:fix": "vp lint --fix && vp fmt",
89
89
  "typecheck": "tsc --noEmit --skipLibCheck",
90
+ "typecheck:dist": "tsc -p tsconfig.dist.json",
90
91
  "test": "vp test run",
91
92
  "test:watch": "vp test watch",
92
- "release": "pnpm test && pnpm build && changelogen --release --push"
93
+ "release": "pnpm test && pnpm build && pnpm typecheck:dist && changelogen --release --push"
93
94
  }
94
95
  }