@jeffjassky/telemetry 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -110,7 +110,7 @@ the full suite in CI. `react` and `vue` are optional peers for their client
110
110
  entries.
111
111
 
112
112
  Entry points: `.` (server), `/core`, `/web`, `/react`, `/vue`, `/electron`,
113
- `/cli`.
113
+ `/cli`, `/mcp` (agent tools), `/mcp/sdk` (official-SDK seam).
114
114
 
115
115
  ## Try it
116
116
 
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ // src/server/mcp-sdk.ts
4
+ function registerTelemetryTools(server, tools) {
5
+ for (const t of tools) {
6
+ server.registerTool(
7
+ t.name,
8
+ { title: t.title, description: t.description, inputSchema: t.inputSchema.shape },
9
+ async (args, extra) => {
10
+ const data = await t.handler(args, extra);
11
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
12
+ }
13
+ );
14
+ }
15
+ }
16
+
17
+ exports.registerTelemetryTools = registerTelemetryTools;
18
+ //# sourceMappingURL=mcp-sdk.cjs.map
19
+ //# sourceMappingURL=mcp-sdk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/mcp-sdk.ts"],"names":[],"mappings":";;;AAgCO,SAAS,sBAAA,CAAuB,QAAuB,KAAA,EAA+B;AAC3F,EAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,IAAA,MAAA,CAAO,YAAA;AAAA,MACL,CAAA,CAAE,IAAA;AAAA,MACF,EAAE,KAAA,EAAO,CAAA,CAAE,KAAA,EAAO,WAAA,EAAa,EAAE,WAAA,EAAa,WAAA,EAAa,CAAA,CAAE,WAAA,CAAY,KAAA,EAAM;AAAA,MAC/E,OAAO,MAAe,KAAA,KAAmB;AACvC,QAAA,MAAM,IAAA,GAAO,MAAM,CAAA,CAAE,OAAA,CAAQ,MAAM,KAAK,CAAA;AACxC,QAAA,OAAO,EAAE,OAAA,EAAS,CAAC,EAAE,MAAM,MAAA,EAAQ,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,IAAA,EAAM,IAAA,EAAM,CAAC,CAAA,EAAG,CAAA,EAAE;AAAA,MAC5E;AAAA,KACF;AAAA,EACF;AACF","file":"mcp-sdk.cjs","sourcesContent":["import type { ToolDescriptor } from './mcp.js';\n\n/**\n * The one seam to the official MCP SDK — isolated here so the core `./mcp`\n * entry stays runtime-free. The SDK is NOT imported: `McpServerLike` is a\n * structural type, so a real `McpServer` from `@modelcontextprotocol/sdk`\n * satisfies it without this package taking a dependency on it. Any server that\n * exposes a compatible `registerTool` works identically.\n *\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n * import { createTelemetryMcp } from '@jeffjassky/telemetry/mcp'\n * import { registerTelemetryTools } from '@jeffjassky/telemetry/mcp/sdk'\n *\n * const server = new McpServer({ name: 'my-app', version: '1.0.0' })\n * registerTelemetryTools(server, createTelemetryMcp({ telemetry, viewerAdapter }))\n */\n\nexport interface McpServerLike {\n registerTool(\n name: string,\n config: { title?: string; description?: string; inputSchema?: Record<string, unknown> },\n handler: (args: any, extra: unknown) => unknown | Promise<unknown>,\n ): unknown;\n}\n\n/**\n * Register every descriptor on an MCP server. The SDK takes a zod raw shape as\n * `inputSchema`, which is exactly `descriptor.inputSchema.shape`. Each handler's\n * JSON result is wrapped as a single text content block — the MCP wire shape —\n * and `extra` (the SDK's per-request context) is forwarded verbatim to the\n * descriptor, which is what its viewerAdapter resolves the scope from.\n */\nexport function registerTelemetryTools(server: McpServerLike, tools: ToolDescriptor[]): void {\n for (const t of tools) {\n server.registerTool(\n t.name,\n { title: t.title, description: t.description, inputSchema: t.inputSchema.shape },\n async (args: unknown, extra: unknown) => {\n const data = await t.handler(args, extra);\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };\n },\n );\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ // src/server/mcp-sdk.ts
2
+ function registerTelemetryTools(server, tools) {
3
+ for (const t of tools) {
4
+ server.registerTool(
5
+ t.name,
6
+ { title: t.title, description: t.description, inputSchema: t.inputSchema.shape },
7
+ async (args, extra) => {
8
+ const data = await t.handler(args, extra);
9
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
10
+ }
11
+ );
12
+ }
13
+ }
14
+
15
+ export { registerTelemetryTools };
16
+ //# sourceMappingURL=mcp-sdk.js.map
17
+ //# sourceMappingURL=mcp-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/mcp-sdk.ts"],"names":[],"mappings":";AAgCO,SAAS,sBAAA,CAAuB,QAAuB,KAAA,EAA+B;AAC3F,EAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,IAAA,MAAA,CAAO,YAAA;AAAA,MACL,CAAA,CAAE,IAAA;AAAA,MACF,EAAE,KAAA,EAAO,CAAA,CAAE,KAAA,EAAO,WAAA,EAAa,EAAE,WAAA,EAAa,WAAA,EAAa,CAAA,CAAE,WAAA,CAAY,KAAA,EAAM;AAAA,MAC/E,OAAO,MAAe,KAAA,KAAmB;AACvC,QAAA,MAAM,IAAA,GAAO,MAAM,CAAA,CAAE,OAAA,CAAQ,MAAM,KAAK,CAAA;AACxC,QAAA,OAAO,EAAE,OAAA,EAAS,CAAC,EAAE,MAAM,MAAA,EAAQ,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,IAAA,EAAM,IAAA,EAAM,CAAC,CAAA,EAAG,CAAA,EAAE;AAAA,MAC5E;AAAA,KACF;AAAA,EACF;AACF","file":"mcp-sdk.js","sourcesContent":["import type { ToolDescriptor } from './mcp.js';\n\n/**\n * The one seam to the official MCP SDK — isolated here so the core `./mcp`\n * entry stays runtime-free. The SDK is NOT imported: `McpServerLike` is a\n * structural type, so a real `McpServer` from `@modelcontextprotocol/sdk`\n * satisfies it without this package taking a dependency on it. Any server that\n * exposes a compatible `registerTool` works identically.\n *\n * import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n * import { createTelemetryMcp } from '@jeffjassky/telemetry/mcp'\n * import { registerTelemetryTools } from '@jeffjassky/telemetry/mcp/sdk'\n *\n * const server = new McpServer({ name: 'my-app', version: '1.0.0' })\n * registerTelemetryTools(server, createTelemetryMcp({ telemetry, viewerAdapter }))\n */\n\nexport interface McpServerLike {\n registerTool(\n name: string,\n config: { title?: string; description?: string; inputSchema?: Record<string, unknown> },\n handler: (args: any, extra: unknown) => unknown | Promise<unknown>,\n ): unknown;\n}\n\n/**\n * Register every descriptor on an MCP server. The SDK takes a zod raw shape as\n * `inputSchema`, which is exactly `descriptor.inputSchema.shape`. Each handler's\n * JSON result is wrapped as a single text content block — the MCP wire shape —\n * and `extra` (the SDK's per-request context) is forwarded verbatim to the\n * descriptor, which is what its viewerAdapter resolves the scope from.\n */\nexport function registerTelemetryTools(server: McpServerLike, tools: ToolDescriptor[]): void {\n for (const t of tools) {\n server.registerTool(\n t.name,\n { title: t.title, description: t.description, inputSchema: t.inputSchema.shape },\n async (args: unknown, extra: unknown) => {\n const data = await t.handler(args, extra);\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };\n },\n );\n }\n}\n"]}