@oat-app/mcp-bridge 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 oat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # @oat-app/mcp-bridge
2
+
3
+ `@oat-app/mcp-bridge` connects stdio MCP clients to the hosted oat MCP endpoint.
4
+
5
+ The oat MCP server remains hosted at `https://oat-blond.vercel.app/api/mcp`.
6
+ This package is only a local transport bridge.
7
+
8
+ ## Claude Code
9
+
10
+ ```bash
11
+ claude mcp add oat \
12
+ --transport stdio \
13
+ --env OAT_MCP_TOKEN=oat_mcp_xxx \
14
+ -- npx -y @oat-app/mcp-bridge
15
+ ```
16
+
17
+ Use a preview endpoint only when needed:
18
+
19
+ ```bash
20
+ claude mcp add oat-preview \
21
+ --transport stdio \
22
+ --env OAT_MCP_TOKEN=oat_mcp_xxx \
23
+ --env OAT_MCP_URL=https://YOUR_PREVIEW_DOMAIN/api/mcp \
24
+ -- npx -y @oat-app/mcp-bridge
25
+ ```
26
+
27
+ Verify with:
28
+
29
+ ```bash
30
+ claude mcp list
31
+ claude mcp get oat
32
+ ```
33
+
34
+ ## Generic MCP JSON
35
+
36
+ Use this form for clients that accept `mcpServers` JSON.
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "oat": {
42
+ "command": "npx",
43
+ "args": ["-y", "@oat-app/mcp-bridge"],
44
+ "env": {
45
+ "OAT_MCP_TOKEN": "oat_mcp_xxx"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Claude Desktop
53
+
54
+ Add the same server entry to `claude_desktop_config.json`.
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "oat": {
60
+ "command": "npx",
61
+ "args": ["-y", "@oat-app/mcp-bridge"],
62
+ "env": {
63
+ "OAT_MCP_TOKEN": "oat_mcp_xxx"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Codex
71
+
72
+ Add this to `~/.codex/config.toml`:
73
+
74
+ ```toml
75
+ [mcp_servers.oat]
76
+ command = "npx"
77
+ args = ["-y", "@oat-app/mcp-bridge"]
78
+ env = { OAT_MCP_TOKEN = "oat_mcp_xxx" }
79
+ ```
80
+
81
+ ## ChatGPT
82
+
83
+ ChatGPT does not use this stdio bridge package. For ChatGPT, test the hosted
84
+ remote MCP endpoint directly:
85
+
86
+ ```text
87
+ https://oat-blond.vercel.app/api/mcp
88
+ ```
89
+
90
+ ## Environment
91
+
92
+ | Variable | Required | Description |
93
+ | --- | --- | --- |
94
+ | `OAT_MCP_TOKEN` | Yes | oat MCP token from `/settings/mcp` |
95
+ | `OAT_MCP_URL` | No | Endpoint override. Defaults to `https://oat-blond.vercel.app/api/mcp` |
96
+ | `OAT_MCP_DEBUG` | No | Set to `1` for stderr debug logs |
97
+ | `OAT_MCP_TIMEOUT_MS` | No | Request timeout. Defaults to `30000` |
98
+
99
+ Tokens are accepted only through environment variables. `--token` and `--url`
100
+ arguments are intentionally not supported.
101
+
102
+ ## Debugging
103
+
104
+ ```json
105
+ {
106
+ "env": {
107
+ "OAT_MCP_TOKEN": "oat_mcp_xxx",
108
+ "OAT_MCP_DEBUG": "1"
109
+ }
110
+ }
111
+ ```
112
+
113
+ Debug logs are written to stderr. stdout is reserved for MCP protocol messages.
114
+ Token values are not printed.
115
+
116
+ ## Local Smoke Test
117
+
118
+ ```bash
119
+ OAT_MCP_TOKEN=oat_mcp_xxx pnpm --filter @oat-app/mcp-bridge smoke
120
+ ```
121
+
122
+ Use `OAT_MCP_URL` to test a preview deployment.
@@ -0,0 +1,3 @@
1
+ import type { BridgeConfig } from "./config.js";
2
+ import type { Logger } from "./logger.js";
3
+ export declare function runBridge(config: BridgeConfig, logger: Logger): Promise<void>;
package/dist/bridge.js ADDED
@@ -0,0 +1,39 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
+ import { PACKAGE_NAME, PACKAGE_VERSION } from "./constants.js";
5
+ import { RemoteMcpClient } from "./remote.js";
6
+ export async function runBridge(config, logger) {
7
+ const remote = new RemoteMcpClient(config, logger);
8
+ await remote.connect();
9
+ const server = new Server({
10
+ name: PACKAGE_NAME,
11
+ version: PACKAGE_VERSION,
12
+ }, {
13
+ capabilities: {
14
+ tools: {},
15
+ },
16
+ });
17
+ server.setRequestHandler(ListToolsRequestSchema, (request) => remote.listTools(request.params));
18
+ server.setRequestHandler(CallToolRequestSchema, (request) => remote.callTool(request.params));
19
+ const transport = new StdioServerTransport();
20
+ transport.onerror = (error) => {
21
+ logger.error("stdio transport error", { message: error.message });
22
+ };
23
+ const close = async () => {
24
+ await server.close();
25
+ await remote.close();
26
+ };
27
+ process.once("SIGINT", () => {
28
+ close()
29
+ .catch((error) => {
30
+ logger.error("failed to close bridge", {
31
+ message: error instanceof Error ? error.message : String(error),
32
+ });
33
+ })
34
+ .finally(() => process.exit(0));
35
+ });
36
+ await server.connect(transport);
37
+ logger.debug("stdio bridge started", { url: config.url.toString() });
38
+ }
39
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAoB,EACpB,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IAEvB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,eAAe;KACzB,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;SACV;KACF,CACF,CAAC;IAEF,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE,CAC3D,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CACjC,CAAC;IACF,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CAC1D,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAChC,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,SAAS,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE;QAC5B,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;QACvB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC1B,KAAK,EAAE;aACJ,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE;gBACrC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC,CAAC;QACL,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface BridgeConfig {
2
+ url: URL;
3
+ token: string;
4
+ debug: boolean;
5
+ timeoutMs: number;
6
+ protocolVersion: string;
7
+ userAgent: string;
8
+ }
9
+ export declare class ConfigError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ export declare function loadConfig(env?: Record<string, string | undefined>): BridgeConfig;
package/dist/config.js ADDED
@@ -0,0 +1,39 @@
1
+ import { DEFAULT_MCP_URL, DEFAULT_TIMEOUT_MS, MCP_PROTOCOL_VERSION, PACKAGE_NAME, PACKAGE_VERSION, } from "./constants.js";
2
+ export class ConfigError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "ConfigError";
6
+ }
7
+ }
8
+ function parseTimeout(value) {
9
+ if (!value)
10
+ return DEFAULT_TIMEOUT_MS;
11
+ const timeoutMs = Number(value);
12
+ if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
13
+ throw new ConfigError("OAT_MCP_TIMEOUT_MS must be a positive integer.");
14
+ }
15
+ return timeoutMs;
16
+ }
17
+ function parseUrl(value) {
18
+ try {
19
+ return new URL(value ?? DEFAULT_MCP_URL);
20
+ }
21
+ catch {
22
+ throw new ConfigError("OAT_MCP_URL must be a valid URL.");
23
+ }
24
+ }
25
+ export function loadConfig(env = process.env) {
26
+ const token = env.OAT_MCP_TOKEN?.trim();
27
+ if (!token) {
28
+ throw new ConfigError("OAT_MCP_TOKEN is required.");
29
+ }
30
+ return {
31
+ url: parseUrl(env.OAT_MCP_URL?.trim() || undefined),
32
+ token,
33
+ debug: env.OAT_MCP_DEBUG === "1" || env.OAT_MCP_DEBUG === "true",
34
+ timeoutMs: parseTimeout(env.OAT_MCP_TIMEOUT_MS),
35
+ protocolVersion: MCP_PROTOCOL_VERSION,
36
+ userAgent: `${PACKAGE_NAME}/${PACKAGE_VERSION}`,
37
+ };
38
+ }
39
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAWxB,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,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.0";
3
+ export declare const DEFAULT_MCP_URL = "https://oat-blond.vercel.app/api/mcp";
4
+ export declare const MCP_PROTOCOL_VERSION = "2025-06-18";
5
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
@@ -0,0 +1,6 @@
1
+ export const PACKAGE_NAME = "@oat-app/mcp-bridge";
2
+ export const PACKAGE_VERSION = "0.1.0";
3
+ export const DEFAULT_MCP_URL = "https://oat-blond.vercel.app/api/mcp";
4
+ export const MCP_PROTOCOL_VERSION = "2025-06-18";
5
+ export const DEFAULT_TIMEOUT_MS = 30_000;
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAC;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import { runBridge } from "./bridge.js";
3
+ import { loadConfig } from "./config.js";
4
+ import { PACKAGE_NAME, PACKAGE_VERSION } from "./constants.js";
5
+ import { createLogger } from "./logger.js";
6
+ function printHelp() {
7
+ process.stdout.write(`${PACKAGE_NAME} ${PACKAGE_VERSION}
8
+
9
+ Usage:
10
+ npx -y ${PACKAGE_NAME}
11
+
12
+ Environment:
13
+ OAT_MCP_TOKEN Required oat MCP token.
14
+ OAT_MCP_URL Optional endpoint override.
15
+ OAT_MCP_DEBUG Set to 1 for stderr debug logs.
16
+ OAT_MCP_TIMEOUT_MS Optional request timeout in milliseconds.
17
+ `);
18
+ }
19
+ async function main() {
20
+ const [arg] = process.argv.slice(2);
21
+ if (arg === "--help" || arg === "-h") {
22
+ printHelp();
23
+ return;
24
+ }
25
+ if (arg === "--version" || arg === "-v") {
26
+ process.stdout.write(`${PACKAGE_VERSION}\n`);
27
+ return;
28
+ }
29
+ if (arg) {
30
+ process.stderr.write(`Unknown argument: ${arg}\n`);
31
+ process.exitCode = 1;
32
+ return;
33
+ }
34
+ const config = loadConfig();
35
+ const logger = createLogger(config.debug);
36
+ await runBridge(config, logger);
37
+ }
38
+ main().catch((error) => {
39
+ process.stderr.write(`[oat-mcp-bridge] ${error instanceof Error ? error.message : String(error)}\n`);
40
+ process.exit(1);
41
+ });
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,SAAS,SAAS;IAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,eAAe;;;WAG9C,YAAY;;;;;;;CAOtB,CAAC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEpC,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACrC,SAAS,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IAED,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,eAAe,IAAI,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IAED,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;QACnD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oBAAoB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC/E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export type JsonRpcId = string | number | null;
2
+ export interface JsonRpcErrorObject {
3
+ code: number;
4
+ message: string;
5
+ data?: unknown;
6
+ }
7
+ export interface JsonRpcResponse {
8
+ jsonrpc: "2.0";
9
+ id: JsonRpcId;
10
+ result?: unknown;
11
+ error?: JsonRpcErrorObject;
12
+ }
13
+ export declare function isJsonRpcResponse(value: unknown): value is JsonRpcResponse;
14
+ export declare function jsonRpcError(id: JsonRpcId, code: number, message: string, data?: unknown): JsonRpcResponse;
@@ -0,0 +1,15 @@
1
+ export function isJsonRpcResponse(value) {
2
+ if (!value || typeof value !== "object")
3
+ return false;
4
+ const candidate = value;
5
+ return (candidate.jsonrpc === "2.0" &&
6
+ ("result" in candidate || "error" in candidate));
7
+ }
8
+ export function jsonRpcError(id, code, message, data) {
9
+ return {
10
+ jsonrpc: "2.0",
11
+ id,
12
+ error: data === undefined ? { code, message } : { code, message, data },
13
+ };
14
+ }
15
+ //# sourceMappingURL=json-rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../src/json-rpc.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEtD,MAAM,SAAS,GAAG,KAAgC,CAAC;IACnD,OAAO,CACL,SAAS,CAAC,OAAO,KAAK,KAAK;QAC3B,CAAC,QAAQ,IAAI,SAAS,IAAI,OAAO,IAAI,SAAS,CAAC,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,EAAa,EACb,IAAY,EACZ,OAAe,EACf,IAAc;IAEd,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE;QACF,KAAK,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;KACxE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface Logger {
2
+ debug(message: string, fields?: Record<string, unknown>): void;
3
+ error(message: string, fields?: Record<string, unknown>): void;
4
+ }
5
+ export declare function createLogger(debugEnabled: boolean): Logger;
package/dist/logger.js ADDED
@@ -0,0 +1,21 @@
1
+ function safeFields(fields) {
2
+ if (!fields)
3
+ return "";
4
+ const sanitized = Object.fromEntries(Object.entries(fields).filter(([key]) => !key.toLowerCase().includes("token")));
5
+ if (Object.keys(sanitized).length === 0)
6
+ return "";
7
+ return ` ${JSON.stringify(sanitized)}`;
8
+ }
9
+ export function createLogger(debugEnabled) {
10
+ return {
11
+ debug(message, fields) {
12
+ if (!debugEnabled)
13
+ return;
14
+ process.stderr.write(`[oat-mcp-bridge] ${message}${safeFields(fields)}\n`);
15
+ },
16
+ error(message, fields) {
17
+ process.stderr.write(`[oat-mcp-bridge] ${message}${safeFields(fields)}\n`);
18
+ },
19
+ };
20
+ }
21
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAKA,SAAS,UAAU,CAAC,MAA2C;IAC7D,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEvB,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAClC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAC3B,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAChD,CACF,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,YAAqB;IAChD,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,MAAM;YACnB,IAAI,CAAC,YAAY;gBAAE,OAAO;YAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oBAAoB,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CACrD,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,MAAM;YACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oBAAoB,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CACrD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,150 @@
1
+ import type { CallToolRequest, ListToolsRequest } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { BridgeConfig } from "./config.js";
3
+ import type { Logger } from "./logger.js";
4
+ export declare class RemoteMcpClient {
5
+ private readonly config;
6
+ private readonly logger;
7
+ private readonly client;
8
+ private readonly transport;
9
+ constructor(config: BridgeConfig, logger: Logger);
10
+ connect(): Promise<void>;
11
+ close(): Promise<void>;
12
+ listTools(params?: ListToolsRequest["params"]): Promise<{
13
+ [x: string]: unknown;
14
+ tools: {
15
+ inputSchema: {
16
+ [x: string]: unknown;
17
+ type: "object";
18
+ properties?: Record<string, object> | undefined;
19
+ required?: string[] | undefined;
20
+ };
21
+ name: string;
22
+ description?: string | undefined;
23
+ outputSchema?: {
24
+ [x: string]: unknown;
25
+ type: "object";
26
+ properties?: Record<string, object> | undefined;
27
+ required?: string[] | undefined;
28
+ } | undefined;
29
+ annotations?: {
30
+ title?: string | undefined;
31
+ readOnlyHint?: boolean | undefined;
32
+ destructiveHint?: boolean | undefined;
33
+ idempotentHint?: boolean | undefined;
34
+ openWorldHint?: boolean | undefined;
35
+ } | undefined;
36
+ execution?: {
37
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
38
+ } | undefined;
39
+ _meta?: Record<string, unknown> | undefined;
40
+ icons?: {
41
+ src: string;
42
+ mimeType?: string | undefined;
43
+ sizes?: string[] | undefined;
44
+ theme?: "light" | "dark" | undefined;
45
+ }[] | undefined;
46
+ title?: string | undefined;
47
+ }[];
48
+ _meta?: {
49
+ [x: string]: unknown;
50
+ progressToken?: string | number | undefined;
51
+ "io.modelcontextprotocol/related-task"?: {
52
+ taskId: string;
53
+ } | undefined;
54
+ } | undefined;
55
+ nextCursor?: string | undefined;
56
+ }>;
57
+ callTool(params: CallToolRequest["params"]): Promise<{
58
+ [x: string]: unknown;
59
+ content: ({
60
+ type: "text";
61
+ text: string;
62
+ annotations?: {
63
+ audience?: ("user" | "assistant")[] | undefined;
64
+ priority?: number | undefined;
65
+ lastModified?: string | undefined;
66
+ } | undefined;
67
+ _meta?: Record<string, unknown> | undefined;
68
+ } | {
69
+ type: "image";
70
+ data: string;
71
+ mimeType: string;
72
+ annotations?: {
73
+ audience?: ("user" | "assistant")[] | undefined;
74
+ priority?: number | undefined;
75
+ lastModified?: string | undefined;
76
+ } | undefined;
77
+ _meta?: Record<string, unknown> | undefined;
78
+ } | {
79
+ type: "audio";
80
+ data: string;
81
+ mimeType: string;
82
+ annotations?: {
83
+ audience?: ("user" | "assistant")[] | undefined;
84
+ priority?: number | undefined;
85
+ lastModified?: string | undefined;
86
+ } | undefined;
87
+ _meta?: Record<string, unknown> | undefined;
88
+ } | {
89
+ type: "resource";
90
+ resource: {
91
+ uri: string;
92
+ text: string;
93
+ mimeType?: string | undefined;
94
+ _meta?: Record<string, unknown> | undefined;
95
+ } | {
96
+ uri: string;
97
+ blob: string;
98
+ mimeType?: string | undefined;
99
+ _meta?: Record<string, unknown> | undefined;
100
+ };
101
+ annotations?: {
102
+ audience?: ("user" | "assistant")[] | undefined;
103
+ priority?: number | undefined;
104
+ lastModified?: string | undefined;
105
+ } | undefined;
106
+ _meta?: Record<string, unknown> | undefined;
107
+ } | {
108
+ uri: string;
109
+ name: string;
110
+ type: "resource_link";
111
+ description?: string | undefined;
112
+ mimeType?: string | undefined;
113
+ size?: number | undefined;
114
+ annotations?: {
115
+ audience?: ("user" | "assistant")[] | undefined;
116
+ priority?: number | undefined;
117
+ lastModified?: string | undefined;
118
+ } | undefined;
119
+ _meta?: {
120
+ [x: string]: unknown;
121
+ } | undefined;
122
+ icons?: {
123
+ src: string;
124
+ mimeType?: string | undefined;
125
+ sizes?: string[] | undefined;
126
+ theme?: "light" | "dark" | undefined;
127
+ }[] | undefined;
128
+ title?: string | undefined;
129
+ })[];
130
+ _meta?: {
131
+ [x: string]: unknown;
132
+ progressToken?: string | number | undefined;
133
+ "io.modelcontextprotocol/related-task"?: {
134
+ taskId: string;
135
+ } | undefined;
136
+ } | undefined;
137
+ structuredContent?: Record<string, unknown> | undefined;
138
+ isError?: boolean | undefined;
139
+ } | {
140
+ [x: string]: unknown;
141
+ toolResult: unknown;
142
+ _meta?: {
143
+ [x: string]: unknown;
144
+ progressToken?: string | number | undefined;
145
+ "io.modelcontextprotocol/related-task"?: {
146
+ taskId: string;
147
+ } | undefined;
148
+ } | undefined;
149
+ }>;
150
+ }
package/dist/remote.js ADDED
@@ -0,0 +1,72 @@
1
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
3
+ import { PACKAGE_NAME, PACKAGE_VERSION } from "./constants.js";
4
+ export class RemoteMcpClient {
5
+ config;
6
+ logger;
7
+ client;
8
+ transport;
9
+ constructor(config, logger) {
10
+ this.config = config;
11
+ this.logger = logger;
12
+ this.client = new Client({
13
+ name: PACKAGE_NAME,
14
+ version: PACKAGE_VERSION,
15
+ });
16
+ this.transport = new StreamableHTTPClientTransport(config.url, {
17
+ requestInit: {
18
+ headers: {
19
+ Authorization: `Bearer ${config.token}`,
20
+ "User-Agent": config.userAgent,
21
+ "X-Oat-Mcp-Bridge": PACKAGE_NAME,
22
+ },
23
+ },
24
+ });
25
+ this.transport.setProtocolVersion(config.protocolVersion);
26
+ }
27
+ async connect() {
28
+ const startedAt = Date.now();
29
+ this.logger.debug("connecting remote MCP", {
30
+ url: this.config.url.toString(),
31
+ timeoutMs: this.config.timeoutMs,
32
+ });
33
+ await this.client.connect(this.transport, {
34
+ timeout: this.config.timeoutMs,
35
+ });
36
+ this.logger.debug("connected remote MCP", {
37
+ durationMs: Date.now() - startedAt,
38
+ });
39
+ }
40
+ async close() {
41
+ try {
42
+ await this.transport.terminateSession();
43
+ }
44
+ catch {
45
+ // The oat v0 endpoint is stateless and may not support session DELETE.
46
+ }
47
+ await this.client.close();
48
+ }
49
+ async listTools(params) {
50
+ const startedAt = Date.now();
51
+ const result = await this.client.listTools(params, {
52
+ timeout: this.config.timeoutMs,
53
+ });
54
+ this.logger.debug("forwarded tools/list", {
55
+ durationMs: Date.now() - startedAt,
56
+ toolCount: result.tools.length,
57
+ });
58
+ return result;
59
+ }
60
+ async callTool(params) {
61
+ const startedAt = Date.now();
62
+ const result = await this.client.callTool(params, undefined, {
63
+ timeout: this.config.timeoutMs,
64
+ });
65
+ this.logger.debug("forwarded tools/call", {
66
+ durationMs: Date.now() - startedAt,
67
+ toolName: params.name,
68
+ });
69
+ return result;
70
+ }
71
+ }
72
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAMnG,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG/D,MAAM,OAAO,eAAe;IAKP;IACA;IALF,MAAM,CAAS;IACf,SAAS,CAAgC;IAE1D,YACmB,MAAoB,EACpB,MAAc;QADd,WAAM,GAAN,MAAM,CAAc;QACpB,WAAM,GAAN,MAAM,CAAQ;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,IAAI,6BAA6B,CAAC,MAAM,CAAC,GAAG,EAAE;YAC7D,WAAW,EAAE;gBACX,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE;oBACvC,YAAY,EAAE,MAAM,CAAC,SAAS;oBAC9B,kBAAkB,EAAE,YAAY;iBACjC;aACF;SACF,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE;YACzC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,Q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IAAI,CAAC,MAAM,CAAC,SAAS;SAC/B,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;YACxC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAClC,QAAQ,EAAE,MAAM,CAAC,IAAI;SACtB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ import { type JsonRpcId, type JsonRpcResponse } from "./json-rpc.js";
2
+ export declare function normalizeRemoteResponse(requestId: JsonRpcId, bodyText: string): JsonRpcResponse;
@@ -0,0 +1,15 @@
1
+ import { isJsonRpcResponse, jsonRpcError, } from "./json-rpc.js";
2
+ export function normalizeRemoteResponse(requestId, bodyText) {
3
+ let parsed;
4
+ try {
5
+ parsed = JSON.parse(bodyText);
6
+ }
7
+ catch {
8
+ return jsonRpcError(requestId, -32603, "oat MCP server returned a non-JSON response.");
9
+ }
10
+ if (isJsonRpcResponse(parsed)) {
11
+ return parsed;
12
+ }
13
+ return jsonRpcError(requestId, -32603, "oat MCP server returned an invalid JSON-RPC response.");
14
+ }
15
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,uBAAuB,CACrC,SAAoB,EACpB,QAAgB;IAEhB,IAAI,MAAe,CAAC;IAEpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CACjB,SAAS,EACT,CAAC,KAAK,EACN,8CAA8C,CAC/C,CAAC;IACJ,CAAC;IAED,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,YAAY,CACjB,SAAS,EACT,CAAC,KAAK,EACN,uDAAuD,CACxD,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@oat-app/mcp-bridge",
3
+ "version": "0.1.0",
4
+ "description": "stdio MCP bridge for the hosted oat MCP endpoint",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "oat-mcp-bridge": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "dependencies": {
16
+ "@modelcontextprotocol/sdk": "^1.23.3"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^20",
20
+ "tsx": "^4.21.0",
21
+ "typescript": "^5",
22
+ "vitest": "^4.1.3"
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "test": "vitest run",
30
+ "smoke": "tsx scripts/smoke.ts"
31
+ }
32
+ }