autotel-skybridge 0.0.0 → 0.1.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
@@ -14,7 +14,7 @@ npm install autotel autotel-skybridge
14
14
  // src/instrumentation.ts: import this first in src/index.ts
15
15
  import { init } from 'autotel';
16
16
 
17
- init({ service: 'my-app', endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT });
17
+ init({ service: 'my-app' }); // reads OTEL_EXPORTER_OTLP_ENDPOINT / _HEADERS
18
18
  ```
19
19
 
20
20
  ```ts
@@ -36,9 +36,9 @@ export const app = new Skybridge({
36
36
 
37
37
  ## What you get
38
38
 
39
- - A `SERVER` span per `tools/call` (`tools/call search`), `resources/read` and `prompts/get`, with the attributes from the OTel MCP semantic conventions (`mcp.method.name`, `gen_ai.tool.name`, `mcp.resource.uri`, ...). This includes Skybridge view resources.
40
- - The span's parent is the caller's trace context from `_meta`, so an instrumented client (`instrumentMcpClient` from `autotel-mcp-instrumentation`) and the server share one trace. Spans started inside a tool nest under it.
41
- - A thrown tool error becomes an `isError` result in Skybridge. The span is marked `ERROR` with `error.type=tool_error` and `mcp.failure.*` grouping, and the original exception (message and stack) is recorded on it.
39
+ - A `SERVER` span per `tools/call` (`tools/call search`), `resources/read` and `prompts/get`, with the attributes from the OTel MCP semantic conventions (`mcp.method.name`, `gen_ai.tool.name`, `mcp.resource.uri`, ...). View resources are included, with the `?v=` cache key dropped from the URI. The duration metric labels tools and prompts by name and leaves resource URIs off, since a URI can expand a template.
40
+ - The caller's trace context in `_meta` parents the span, so an `instrumentMcpClient` caller and your server share one trace. Spans you start inside a tool nest under it.
41
+ - Skybridge answers a thrown tool error with an `isError` result. The span records `ERROR` with the failure text as its status message, `error.type=tool_error`, `mcp.failure.*` grouping, and the original exception. A `createStructuredError` keeps its `why`, `fix` and `code` as `error.*` attributes.
42
42
  - Payload sizes, the `mcp.server.operation.duration` metric, and the security signals from `autotel-mcp-instrumentation`.
43
43
 
44
44
  ## Options
@@ -52,7 +52,11 @@ skybridgeTracing({
52
52
  });
53
53
  ```
54
54
 
55
- Tool annotations and manifest classification are not recorded, because a middleware sees the request, never the tool's registration.
55
+ The middleware runs before the SDK validates the request. `captureToolArgs` and the security classifiers see the arguments as sent, and the span name comes from the requested tool name. A call to an unknown tool gets the bare method name, and the duration metric leaves the name out. Tool annotations and manifest classification come from `instrumentMcpServer`, which sees each tool's registration.
56
+
57
+ ## Vercel
58
+
59
+ `skybridge build` writes Vercel's prebuilt output. Add `protocol: 'http'` (the bundled JSON exporter) and `forceFlushOnShutdown: process.env.VERCEL === '1'` to `init()`, set `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` on the project, and run `vercel deploy --prebuilt`.
56
60
 
57
61
  ## Example
58
62
 
package/dist/index.cjs CHANGED
@@ -35,15 +35,14 @@ const TRACED_METHODS = /* @__PURE__ */ new Map([
35
35
  * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
36
36
  * });
37
37
  * ```
38
- *
39
- * Tool annotations and manifest classification are not available: a
40
- * middleware sees the request, never the tool's registration.
41
38
  */
42
39
  function skybridgeTracing(config) {
43
40
  return (request, extra, next) => {
44
41
  const type = TRACED_METHODS.get(request.method);
45
42
  if (!type || !extra) return next();
46
- const name = String(type === "resource" ? request.params.uri : request.params.name);
43
+ const rawName = type === "resource" ? request.params.uri : request.params.name;
44
+ if (typeof rawName !== "string") return next();
45
+ const name = type === "resource" ? rawName.split("?")[0] : rawName;
47
46
  return (0, autotel_mcp_instrumentation.traceMcpHandler)(async () => {
48
47
  const result = await next();
49
48
  const error = TOOL_ERROR in extra ? extra[TOOL_ERROR] : void 0;
@@ -54,7 +53,7 @@ function skybridgeTracing(config) {
54
53
  name,
55
54
  resourceUri: type === "resource" ? name : void 0,
56
55
  config
57
- })(type === "resource" ? name : request.params.arguments, extra);
56
+ })(type === "resource" ? rawName : request.params.arguments, extra);
58
57
  };
59
58
  }
60
59
  //#endregion
package/dist/index.d.cts CHANGED
@@ -14,9 +14,6 @@ import { McpMiddlewareFn } from "skybridge/server";
14
14
  * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
15
15
  * });
16
16
  * ```
17
- *
18
- * Tool annotations and manifest classification are not available: a
19
- * middleware sees the request, never the tool's registration.
20
17
  */
21
18
  export declare function skybridgeTracing(config?: McpInstrumentationConfig$1): McpMiddlewareFn;
22
19
  //#endregion
package/dist/index.d.ts CHANGED
@@ -14,9 +14,6 @@ import { McpMiddlewareFn } from "skybridge/server";
14
14
  * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
15
15
  * });
16
16
  * ```
17
- *
18
- * Tool annotations and manifest classification are not available: a
19
- * middleware sees the request, never the tool's registration.
20
17
  */
21
18
  export declare function skybridgeTracing(config?: McpInstrumentationConfig$1): McpMiddlewareFn;
22
19
  //#endregion
package/dist/index.js CHANGED
@@ -34,15 +34,14 @@ const TRACED_METHODS = /* @__PURE__ */ new Map([
34
34
  * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
35
35
  * });
36
36
  * ```
37
- *
38
- * Tool annotations and manifest classification are not available: a
39
- * middleware sees the request, never the tool's registration.
40
37
  */
41
38
  function skybridgeTracing(config) {
42
39
  return (request, extra, next) => {
43
40
  const type = TRACED_METHODS.get(request.method);
44
41
  if (!type || !extra) return next();
45
- const name = String(type === "resource" ? request.params.uri : request.params.name);
42
+ const rawName = type === "resource" ? request.params.uri : request.params.name;
43
+ if (typeof rawName !== "string") return next();
44
+ const name = type === "resource" ? rawName.split("?")[0] : rawName;
46
45
  return traceMcpHandler(async () => {
47
46
  const result = await next();
48
47
  const error = TOOL_ERROR in extra ? extra[TOOL_ERROR] : void 0;
@@ -53,7 +52,7 @@ function skybridgeTracing(config) {
53
52
  name,
54
53
  resourceUri: type === "resource" ? name : void 0,
55
54
  config
56
- })(type === "resource" ? name : request.params.arguments, extra);
55
+ })(type === "resource" ? rawName : request.params.arguments, extra);
57
56
  };
58
57
  }
59
58
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-skybridge",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "description": "OpenTelemetry for Skybridge MCP Apps, powered by autotel",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -20,14 +20,6 @@
20
20
  "LICENSE",
21
21
  "NOTICE"
22
22
  ],
23
- "scripts": {
24
- "build": "tsdown",
25
- "dev": "tsdown --watch",
26
- "type-check": "tsc --noEmit",
27
- "lint": "oxlint -c oxlint.json --disable-nested-config src",
28
- "test": "vitest run",
29
- "clean": "rimraf dist"
30
- },
31
23
  "keywords": [
32
24
  "opentelemetry",
33
25
  "otel",
@@ -40,7 +32,7 @@
40
32
  ],
41
33
  "author": "Jag Reehal <jag@jagreehal.com> (https://jagreehal.com)",
42
34
  "dependencies": {
43
- "autotel-mcp-instrumentation": "workspace:*"
35
+ "autotel-mcp-instrumentation": "59.1.0"
44
36
  },
45
37
  "peerDependencies": {
46
38
  "autotel": "*",
@@ -54,7 +46,7 @@
54
46
  "@opentelemetry/sdk-trace-base": "^2.11.0",
55
47
  "@opentelemetry/sdk-trace-node": "^2.11.0",
56
48
  "@types/node": "^26.6.3",
57
- "autotel": "workspace:*",
49
+ "autotel": "7.10.1",
58
50
  "skybridge": "^2.0.1",
59
51
  "tsdown": "^0.23.0",
60
52
  "typescript": "^7.0.2",
@@ -69,5 +61,13 @@
69
61
  "bugs": {
70
62
  "url": "https://github.com/jagreehal/autotel/issues"
71
63
  },
72
- "homepage": "https://github.com/jagreehal/autotel/tree/main/packages/autotel-skybridge#readme"
73
- }
64
+ "homepage": "https://github.com/jagreehal/autotel/tree/main/packages/autotel-skybridge#readme",
65
+ "scripts": {
66
+ "build": "tsdown",
67
+ "dev": "tsdown --watch",
68
+ "type-check": "tsc --noEmit",
69
+ "lint": "oxlint -c oxlint.json --disable-nested-config src",
70
+ "test": "vitest run",
71
+ "clean": "rimraf dist"
72
+ }
73
+ }