autotel-skybridge 0.0.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 ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty
20
+ percent (50%) or more of the outstanding shares, or (iii) beneficial
21
+ ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source,
28
+ and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that
36
+ is included in or attached to the work (an example is provided in the
37
+ Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as
42
+ a whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or
44
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
45
+ Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the
52
+ purposes of this definition, "submitted" means any form of electronic,
53
+ verbal, or written communication sent to the Licensor or its
54
+ representatives, including but not limited to communication on electronic
55
+ mailing lists, source code control systems, and issue tracking systems that
56
+ are managed by, or on behalf of, the Licensor for the purpose of discussing
57
+ and improving the Work, but excluding communication that is conspicuously
58
+ marked or otherwise designated in writing by the copyright owner as "Not a
59
+ Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
62
+ behalf of whom a Contribution has been received by Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
66
+ License, each Contributor hereby grants to You a perpetual, worldwide,
67
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
68
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
69
+ sublicense, and distribute the Work and such Derivative Works in Source or
70
+ Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of this
73
+ License, each Contributor hereby grants to You a perpetual, worldwide,
74
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
75
+ this section) patent license to make, have made, use, offer to sell, sell,
76
+ import, and otherwise transfer the Work, where such license applies only to
77
+ those patent claims licensable by such Contributor that are necessarily
78
+ infringed by their Contribution(s) alone or by combination of their
79
+ Contribution(s) with the Work to which such Contribution(s) was submitted.
80
+ If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or
83
+ contributory patent infringement, then any patent licenses granted to You
84
+ under this License for that Work shall terminate as of the date such
85
+ litigation is filed.
86
+
87
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
88
+ Derivative Works thereof in any medium, with or without modifications, and
89
+ in Source or Object form, provided that You meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative Works
92
+ a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works that
98
+ You distribute, all copyright, patent, trademark, and attribution notices
99
+ from the Source form of the Work, excluding those notices that do not
100
+ pertain to any part of the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, then any Derivative Works that You distribute must include a
104
+ readable copy of the attribution notices contained within such NOTICE file,
105
+ excluding those notices that do not pertain to any part of the Derivative
106
+ Works, in at least one of the following places: within a NOTICE text file
107
+ distributed as part of the Derivative Works; within the Source form or
108
+ documentation, if provided along with the Derivative Works; or, within a
109
+ display generated by the Derivative Works, if and wherever such third-party
110
+ notices normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License. You may add Your
112
+ own attribution notices within Derivative Works that You distribute,
113
+ alongside or as an addendum to the NOTICE text from the Work, provided that
114
+ such additional attribution notices cannot be construed as modifying the
115
+ License.
116
+
117
+ You may add Your own copyright statement to Your modifications and may
118
+ provide additional or different license terms and conditions for use,
119
+ reproduction, or distribution of Your modifications, or for any such
120
+ Derivative Works as a whole, provided Your use, reproduction, and
121
+ distribution of the Work otherwise complies with the conditions stated in
122
+ this License.
123
+
124
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
125
+ Contribution intentionally submitted for inclusion in the Work by You to
126
+ the Licensor shall be under the terms and conditions of this License,
127
+ without any additional terms or conditions. Notwithstanding the above,
128
+ nothing herein shall supersede or modify the terms of any separate license
129
+ agreement you may have executed with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor, except
133
+ as required for reasonable and customary use in describing the origin of
134
+ the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to
137
+ in writing, Licensor provides the Work (and each Contributor provides its
138
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
139
+ KIND, either express or implied, including, without limitation, any
140
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
141
+ FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
142
+ determining the appropriateness of using or redistributing the Work and
143
+ assume any risks associated with Your exercise of permissions under this
144
+ License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory, whether
147
+ in tort (including negligence), contract, or otherwise, unless required by
148
+ applicable law (such as deliberate and grossly negligent acts) or agreed to
149
+ in writing, shall any Contributor be liable to You for damages, including
150
+ any direct, indirect, special, incidental, or consequential damages of any
151
+ character arising as a result of this License or out of the use or
152
+ inability to use the Work (including but not limited to damages for loss of
153
+ goodwill, work stoppage, computer failure or malfunction, or any and all
154
+ other commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Additional Liability. While redistributing the
158
+ Work or Derivative Works thereof, You may choose to offer, and charge a fee
159
+ for, acceptance of support, warranty, indemnity, or other liability
160
+ obligations and/or rights consistent with this License. However, in
161
+ accepting such obligations, You may act only on Your own behalf and on Your
162
+ sole responsibility, not on behalf of any other Contributor, and only if
163
+ You agree to indemnify, defend, and hold each Contributor harmless for any
164
+ liability incurred by, or claims asserted against, such Contributor by
165
+ reason of your accepting any such warranty or additional liability.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+ APPENDIX: How to apply the Apache License to your work.
170
+
171
+ To apply the Apache License to your work, attach the following boilerplate
172
+ notice, with the fields enclosed by brackets "[]" replaced with your own
173
+ identifying information. (Don't include the brackets!) The text should be
174
+ enclosed in the appropriate comment syntax for the file format. We also
175
+ recommend that a file or class name and description of purpose be included
176
+ on the same "printed page" as the copyright notice for easier
177
+ identification within third-party archives.
178
+
179
+ Copyright [yyyy] [name of copyright owner]
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ autotel
2
+ Copyright 2026 Jag Reehal
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
5
+ See the LICENSE file for the full license text.
6
+
7
+ "autotel" is a trademark of Jag Reehal. The Apache License, Version 2.0
8
+ does not grant rights to use the "autotel" name. See TRADEMARKS.md for
9
+ the trademark policy.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # autotel-skybridge
2
+
3
+ OpenTelemetry for [Skybridge](https://github.com/alpic-ai/skybridge) MCP Apps. One middleware traces every tool call, resource read and prompt, and sends the spans to any OTLP backend.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install autotel autotel-skybridge
9
+ ```
10
+
11
+ ## Use
12
+
13
+ ```ts
14
+ // src/instrumentation.ts: import this first in src/index.ts
15
+ import { init } from 'autotel';
16
+
17
+ init({ service: 'my-app', endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT });
18
+ ```
19
+
20
+ ```ts
21
+ // src/server.ts
22
+ import { skybridgeTracing } from 'autotel-skybridge';
23
+ import { Skybridge } from 'skybridge/server';
24
+
25
+ export const app = new Skybridge({
26
+ name: 'my-app',
27
+ version: '1.0.0',
28
+ handler: (server) =>
29
+ server
30
+ .registerTool({ name: 'search' /* ... */ }, async (args) => {
31
+ /* ... */
32
+ })
33
+ .mcpMiddleware(skybridgeTracing()),
34
+ });
35
+ ```
36
+
37
+ ## What you get
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.
42
+ - Payload sizes, the `mcp.server.operation.duration` metric, and the security signals from `autotel-mcp-instrumentation`.
43
+
44
+ ## Options
45
+
46
+ `skybridgeTracing(config)` takes the same `McpInstrumentationConfig` as `instrumentMcpServer`, for example:
47
+
48
+ ```ts
49
+ skybridgeTracing({
50
+ captureToolArgs: true, // off by default: arguments may carry PII
51
+ captureToolResults: false,
52
+ });
53
+ ```
54
+
55
+ Tool annotations and manifest classification are not recorded, because a middleware sees the request, never the tool's registration.
56
+
57
+ ## Example
58
+
59
+ [`apps/example-skybridge`](../../apps/example-skybridge) is a Skybridge app with a React view and a client script that calls it.
package/dist/index.cjs ADDED
@@ -0,0 +1,61 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let autotel = require("autotel");
3
+ let autotel_mcp_instrumentation = require("autotel-mcp-instrumentation");
4
+ //#region src/index.ts
5
+ /**
6
+ * autotel-skybridge - OpenTelemetry for Skybridge MCP Apps
7
+ *
8
+ * One Skybridge middleware that traces `tools/call`, `resources/read` and
9
+ * `prompts/get` with the spans, attributes and metrics of
10
+ * `autotel-mcp-instrumentation`, parented to the caller's `_meta` trace context.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ /**
15
+ * Where Skybridge stores the error a tool handler threw (`getToolError` reads
16
+ * it). Mirrored rather than imported so this package has no runtime Skybridge
17
+ * import; the thrown-error test fails if Skybridge moves it.
18
+ */
19
+ const TOOL_ERROR = Symbol.for("skybridge.toolError");
20
+ const TRACED_METHODS = /* @__PURE__ */ new Map([
21
+ ["tools/call", "tool"],
22
+ ["resources/read", "resource"],
23
+ ["prompts/get", "prompt"]
24
+ ]);
25
+ /**
26
+ * Skybridge middleware that traces every tool call, resource read and prompt.
27
+ *
28
+ * ```ts
29
+ * import { skybridgeTracing } from 'autotel-skybridge';
30
+ *
31
+ * new Skybridge({
32
+ * name: 'my-app',
33
+ * version: '1.0.0',
34
+ * handler: (server) =>
35
+ * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
36
+ * });
37
+ * ```
38
+ *
39
+ * Tool annotations and manifest classification are not available: a
40
+ * middleware sees the request, never the tool's registration.
41
+ */
42
+ function skybridgeTracing(config) {
43
+ return (request, extra, next) => {
44
+ const type = TRACED_METHODS.get(request.method);
45
+ if (!type || !extra) return next();
46
+ const name = String(type === "resource" ? request.params.uri : request.params.name);
47
+ return (0, autotel_mcp_instrumentation.traceMcpHandler)(async () => {
48
+ const result = await next();
49
+ const error = TOOL_ERROR in extra ? extra[TOOL_ERROR] : void 0;
50
+ if (error !== void 0 && config?.captureErrors !== false) autotel.ctx.recordError(error);
51
+ return result;
52
+ }, {
53
+ type,
54
+ name,
55
+ resourceUri: type === "resource" ? name : void 0,
56
+ config
57
+ })(type === "resource" ? name : request.params.arguments, extra);
58
+ };
59
+ }
60
+ //#endregion
61
+ exports.skybridgeTracing = skybridgeTracing;
@@ -0,0 +1,23 @@
1
+ import { McpInstrumentationConfig, McpInstrumentationConfig as McpInstrumentationConfig$1 } from "autotel-mcp-instrumentation";
2
+ import { McpMiddlewareFn } from "skybridge/server";
3
+ //#region src/index.d.ts
4
+ /**
5
+ * Skybridge middleware that traces every tool call, resource read and prompt.
6
+ *
7
+ * ```ts
8
+ * import { skybridgeTracing } from 'autotel-skybridge';
9
+ *
10
+ * new Skybridge({
11
+ * name: 'my-app',
12
+ * version: '1.0.0',
13
+ * handler: (server) =>
14
+ * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
15
+ * });
16
+ * ```
17
+ *
18
+ * Tool annotations and manifest classification are not available: a
19
+ * middleware sees the request, never the tool's registration.
20
+ */
21
+ export declare function skybridgeTracing(config?: McpInstrumentationConfig$1): McpMiddlewareFn;
22
+ //#endregion
23
+ export type { McpInstrumentationConfig };
@@ -0,0 +1,23 @@
1
+ import { McpInstrumentationConfig, McpInstrumentationConfig as McpInstrumentationConfig$1 } from "autotel-mcp-instrumentation";
2
+ import { McpMiddlewareFn } from "skybridge/server";
3
+ //#region src/index.d.ts
4
+ /**
5
+ * Skybridge middleware that traces every tool call, resource read and prompt.
6
+ *
7
+ * ```ts
8
+ * import { skybridgeTracing } from 'autotel-skybridge';
9
+ *
10
+ * new Skybridge({
11
+ * name: 'my-app',
12
+ * version: '1.0.0',
13
+ * handler: (server) =>
14
+ * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
15
+ * });
16
+ * ```
17
+ *
18
+ * Tool annotations and manifest classification are not available: a
19
+ * middleware sees the request, never the tool's registration.
20
+ */
21
+ export declare function skybridgeTracing(config?: McpInstrumentationConfig$1): McpMiddlewareFn;
22
+ //#endregion
23
+ export type { McpInstrumentationConfig };
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ import { ctx } from "autotel";
2
+ import { traceMcpHandler } from "autotel-mcp-instrumentation";
3
+ //#region src/index.ts
4
+ /**
5
+ * autotel-skybridge - OpenTelemetry for Skybridge MCP Apps
6
+ *
7
+ * One Skybridge middleware that traces `tools/call`, `resources/read` and
8
+ * `prompts/get` with the spans, attributes and metrics of
9
+ * `autotel-mcp-instrumentation`, parented to the caller's `_meta` trace context.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ /**
14
+ * Where Skybridge stores the error a tool handler threw (`getToolError` reads
15
+ * it). Mirrored rather than imported so this package has no runtime Skybridge
16
+ * import; the thrown-error test fails if Skybridge moves it.
17
+ */
18
+ const TOOL_ERROR = Symbol.for("skybridge.toolError");
19
+ const TRACED_METHODS = /* @__PURE__ */ new Map([
20
+ ["tools/call", "tool"],
21
+ ["resources/read", "resource"],
22
+ ["prompts/get", "prompt"]
23
+ ]);
24
+ /**
25
+ * Skybridge middleware that traces every tool call, resource read and prompt.
26
+ *
27
+ * ```ts
28
+ * import { skybridgeTracing } from 'autotel-skybridge';
29
+ *
30
+ * new Skybridge({
31
+ * name: 'my-app',
32
+ * version: '1.0.0',
33
+ * handler: (server) =>
34
+ * server.registerTool(...).mcpMiddleware(skybridgeTracing()),
35
+ * });
36
+ * ```
37
+ *
38
+ * Tool annotations and manifest classification are not available: a
39
+ * middleware sees the request, never the tool's registration.
40
+ */
41
+ function skybridgeTracing(config) {
42
+ return (request, extra, next) => {
43
+ const type = TRACED_METHODS.get(request.method);
44
+ if (!type || !extra) return next();
45
+ const name = String(type === "resource" ? request.params.uri : request.params.name);
46
+ return traceMcpHandler(async () => {
47
+ const result = await next();
48
+ const error = TOOL_ERROR in extra ? extra[TOOL_ERROR] : void 0;
49
+ if (error !== void 0 && config?.captureErrors !== false) ctx.recordError(error);
50
+ return result;
51
+ }, {
52
+ type,
53
+ name,
54
+ resourceUri: type === "resource" ? name : void 0,
55
+ config
56
+ })(type === "resource" ? name : request.params.arguments, extra);
57
+ };
58
+ }
59
+ //#endregion
60
+ export { skybridgeTracing };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "autotel-skybridge",
3
+ "version": "0.0.0",
4
+ "description": "OpenTelemetry for Skybridge MCP Apps, powered by autotel",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE",
21
+ "NOTICE"
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
+ "keywords": [
32
+ "opentelemetry",
33
+ "otel",
34
+ "skybridge",
35
+ "mcp",
36
+ "mcp-apps",
37
+ "chatgpt",
38
+ "observability",
39
+ "instrumentation"
40
+ ],
41
+ "author": "Jag Reehal <jag@jagreehal.com> (https://jagreehal.com)",
42
+ "dependencies": {
43
+ "autotel-mcp-instrumentation": "workspace:*"
44
+ },
45
+ "peerDependencies": {
46
+ "autotel": "*",
47
+ "skybridge": ">=2.0.0"
48
+ },
49
+ "devDependencies": {
50
+ "@modelcontextprotocol/client": "^2.1.0",
51
+ "@opentelemetry/api": "^1.9.1",
52
+ "@opentelemetry/context-async-hooks": "^2.11.0",
53
+ "@opentelemetry/core": "^2.11.0",
54
+ "@opentelemetry/sdk-trace-base": "^2.11.0",
55
+ "@opentelemetry/sdk-trace-node": "^2.11.0",
56
+ "@types/node": "^26.6.3",
57
+ "autotel": "workspace:*",
58
+ "skybridge": "^2.0.1",
59
+ "tsdown": "^0.23.0",
60
+ "typescript": "^7.0.2",
61
+ "vitest": "^5.0.2",
62
+ "zod": "^4.2.0"
63
+ },
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "https://github.com/jagreehal/autotel",
67
+ "directory": "packages/autotel-skybridge"
68
+ },
69
+ "bugs": {
70
+ "url": "https://github.com/jagreehal/autotel/issues"
71
+ },
72
+ "homepage": "https://github.com/jagreehal/autotel/tree/main/packages/autotel-skybridge#readme"
73
+ }