@nimbletools/mcp-http-bridge 1.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 NimbleTools
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,175 @@
1
+ # MCP HTTP Bridge
2
+
3
+ Bridge the Model Context Protocol (MCP) stdio interface to HTTP-based MCP services. This allows MCP clients like Claude Code to seamlessly connect to remote MCP servers running over HTTP.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 24.0.0 or higher
8
+ - npm 10.0.0 or higher
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install -g @nimbletools/mcp-http-bridge
14
+ ```
15
+
16
+ Or use directly with npx:
17
+
18
+ ```bash
19
+ npx @nimbletools/mcp-http-bridge --endpoint "https://..." --token "..."
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Command Line
25
+
26
+ ```bash
27
+ mcp-http-bridge \
28
+ --endpoint "https://api.example.com/mcp" \
29
+ --token "your-bearer-token" \
30
+ --timeout 15000 \
31
+ --retries 2
32
+ ```
33
+
34
+ ### With Claude Code
35
+
36
+ Add to your Claude Code configuration:
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "my-remote-server": {
42
+ "command": "npx",
43
+ "args": [
44
+ "@nimbletools/mcp-http-bridge",
45
+ "--endpoint", "https://api.example.com/mcp",
46
+ "--token", "your-bearer-token"
47
+ ]
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### With Environment Variables
54
+
55
+ For better security, use environment variables:
56
+
57
+ ```json
58
+ {
59
+ "mcpServers": {
60
+ "my-remote-server": {
61
+ "command": "mcp-http-bridge",
62
+ "args": [
63
+ "--endpoint", "https://api.example.com/mcp"
64
+ ],
65
+ "env": {
66
+ "MCP_BEARER_TOKEN": "your-bearer-token"
67
+ }
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ ## Options
74
+
75
+ | Option | Alias | Default | Description |
76
+ |--------|-------|---------|-------------|
77
+ | `--endpoint` | `-e` | *required* | HTTP endpoint for the MCP service |
78
+ | `--token` | `-t` | *required* | Bearer token for authentication |
79
+ | `--timeout` | | `30000` | Request timeout in milliseconds |
80
+ | `--retries` | | `3` | Number of retry attempts |
81
+ | `--verbose` | `-v` | `false` | Enable verbose logging |
82
+
83
+ ## How It Works
84
+
85
+ The bridge acts as a protocol translator:
86
+
87
+ 1. **Input**: Accepts MCP JSON-RPC messages via stdin
88
+ 2. **Translation**: Forwards them as HTTP POST requests to your endpoint
89
+ 3. **Output**: Returns responses via stdout in MCP format
90
+
91
+ ```
92
+ Claude Code ↔ stdio/JSON-RPC ↔ MCP HTTP Bridge ↔ HTTP/JSON ↔ Your MCP Service
93
+ ```
94
+
95
+ ## Authentication
96
+
97
+ The bridge adds Bearer token authentication to all HTTP requests:
98
+
99
+ ```http
100
+ POST /mcp HTTP/1.1
101
+ Authorization: Bearer your-token-here
102
+ Content-Type: application/json
103
+
104
+ {
105
+ "jsonrpc": "2.0",
106
+ "method": "tools/list",
107
+ "id": 1
108
+ }
109
+ ```
110
+
111
+ ## Error Handling
112
+
113
+ - **4xx Client Errors**: Returned immediately (no retries)
114
+ - **5xx Server Errors**: Retried with exponential backoff
115
+ - **Network Errors**: Retried with exponential backoff
116
+ - **Timeouts**: Configurable per request
117
+
118
+ ## Examples
119
+
120
+ ### Basic Usage
121
+ ```bash
122
+ mcp-http-bridge \
123
+ --endpoint "https://mcp.example.com/api" \
124
+ --token "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
125
+ ```
126
+
127
+ ### With Custom Timeout
128
+ ```bash
129
+ mcp-http-bridge \
130
+ --endpoint "https://slow-service.com/mcp" \
131
+ --token "abc123" \
132
+ --timeout 60000 \
133
+ --retries 5
134
+ ```
135
+
136
+ ### Testing Connectivity
137
+ ```bash
138
+ echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | \
139
+ mcp-http-bridge --endpoint "https://api.com/mcp" --token "token"
140
+ ```
141
+
142
+ ## Development
143
+
144
+ ```bash
145
+ # Clone the repository
146
+ git clone https://github.com/nimbletools/mcp-http-bridge.git
147
+ cd mcp-http-bridge
148
+
149
+ # Install dependencies
150
+ npm install
151
+
152
+ # Build TypeScript
153
+ npm run build
154
+
155
+ # Run locally
156
+ npm run dev -- --endpoint "https://..." --token "..."
157
+ ```
158
+
159
+ ## Contributing
160
+
161
+ 1. Fork the repository
162
+ 2. Create a feature branch
163
+ 3. Make your changes
164
+ 4. Add tests if applicable
165
+ 5. Submit a pull request
166
+
167
+ ## License
168
+
169
+ MIT License - see [LICENSE](LICENSE) file for details.
170
+
171
+ ## Support
172
+
173
+ - 🐛 [Report Issues](https://github.com/nimbletools/mcp-http-bridge/issues)
174
+ - 📖 [Documentation](https://github.com/nimbletools/mcp-http-bridge)
175
+ - 💬 [Discussions](https://github.com/nimbletools/mcp-http-bridge/discussions)
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ interface BridgeConfig {
3
+ endpoint: string;
4
+ bearerToken: string;
5
+ timeout: number;
6
+ retries: number;
7
+ }
8
+ export declare class MCPHttpBridge {
9
+ private config;
10
+ private axiosInstance;
11
+ constructor(config: BridgeConfig);
12
+ start(): Promise<void>;
13
+ private handleMCPRequest;
14
+ private processMCPRequest;
15
+ private makeHttpRequest;
16
+ private createErrorResponse;
17
+ private sendResponse;
18
+ private sleep;
19
+ private shutdown;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";AAuBA,UAAU,YAAY;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,aAAa,CAAC;gBAEV,MAAM,EAAE,YAAY;IAW1B,KAAK;YA8BG,gBAAgB;YAmBhB,iBAAiB;YAiBjB,eAAe;IA2B7B,OAAO,CAAC,mBAAmB;IA4B3B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,QAAQ;CAIjB"}
package/dist/bridge.js ADDED
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+ import axios from 'axios';
3
+ export class MCPHttpBridge {
4
+ config;
5
+ axiosInstance;
6
+ constructor(config) {
7
+ this.config = config;
8
+ this.axiosInstance = axios.create({
9
+ timeout: config.timeout,
10
+ headers: {
11
+ 'Authorization': `Bearer ${config.bearerToken}`,
12
+ 'Content-Type': 'application/json',
13
+ },
14
+ });
15
+ }
16
+ async start() {
17
+ process.stdin.setEncoding('utf8');
18
+ let buffer = '';
19
+ process.stdin.on('data', (chunk) => {
20
+ buffer += chunk;
21
+ // Process complete lines (JSON-RPC messages)
22
+ const lines = buffer.split('\n');
23
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
24
+ for (const line of lines) {
25
+ if (line.trim()) {
26
+ this.handleMCPRequest(line.trim());
27
+ }
28
+ }
29
+ });
30
+ process.stdin.on('end', () => {
31
+ if (buffer.trim()) {
32
+ this.handleMCPRequest(buffer.trim());
33
+ }
34
+ });
35
+ // Handle graceful shutdown
36
+ process.on('SIGTERM', () => this.shutdown());
37
+ process.on('SIGINT', () => this.shutdown());
38
+ }
39
+ async handleMCPRequest(requestLine) {
40
+ try {
41
+ const request = JSON.parse(requestLine);
42
+ const response = await this.processMCPRequest(request);
43
+ this.sendResponse(response);
44
+ }
45
+ catch (error) {
46
+ const errorResponse = {
47
+ jsonrpc: '2.0',
48
+ id: undefined,
49
+ error: {
50
+ code: -32700, // Parse error
51
+ message: 'Invalid JSON-RPC request',
52
+ data: error instanceof Error ? error.message : String(error)
53
+ }
54
+ };
55
+ this.sendResponse(errorResponse);
56
+ }
57
+ }
58
+ async processMCPRequest(request) {
59
+ try {
60
+ // Forward the MCP request to the HTTP endpoint
61
+ const httpResponse = await this.makeHttpRequest(request);
62
+ // Return the response from the HTTP service
63
+ return {
64
+ jsonrpc: '2.0',
65
+ id: request.id,
66
+ result: httpResponse.data
67
+ };
68
+ }
69
+ catch (error) {
70
+ return this.createErrorResponse(request.id, error);
71
+ }
72
+ }
73
+ async makeHttpRequest(request) {
74
+ const retries = this.config.retries;
75
+ let lastError;
76
+ for (let attempt = 1; attempt <= retries; attempt++) {
77
+ try {
78
+ const response = await this.axiosInstance.post(this.config.endpoint, request);
79
+ return response;
80
+ }
81
+ catch (error) {
82
+ lastError = error;
83
+ // If it's not a retryable error (4xx), fail immediately
84
+ if (error.response?.status >= 400 && error.response?.status < 500) {
85
+ throw error;
86
+ }
87
+ // Only retry on 5xx server errors or network issues
88
+ if (attempt < retries) {
89
+ await this.sleep(1000 * attempt); // Exponential backoff
90
+ }
91
+ }
92
+ }
93
+ throw lastError;
94
+ }
95
+ createErrorResponse(id, error) {
96
+ let code = -32603; // Internal error
97
+ let message = 'Internal error';
98
+ let data = undefined;
99
+ if (error.response) {
100
+ // HTTP error response
101
+ code = -32000; // Server error
102
+ message = `HTTP ${error.response.status}: ${error.response.statusText}`;
103
+ data = error.response.data;
104
+ }
105
+ else if (error.code === 'ECONNREFUSED') {
106
+ code = -32001;
107
+ message = 'Service unavailable - connection refused';
108
+ }
109
+ else if (error.code === 'ETIMEDOUT') {
110
+ code = -32002;
111
+ message = 'Service timeout';
112
+ }
113
+ else if (error instanceof Error) {
114
+ message = error.message;
115
+ data = error.stack;
116
+ }
117
+ return {
118
+ jsonrpc: '2.0',
119
+ id,
120
+ error: { code, message, data }
121
+ };
122
+ }
123
+ sendResponse(response) {
124
+ process.stdout.write(JSON.stringify(response) + '\n');
125
+ }
126
+ sleep(ms) {
127
+ return new Promise(resolve => setTimeout(resolve, ms));
128
+ }
129
+ shutdown() {
130
+ console.error('Bridge shutting down...');
131
+ process.exit(0);
132
+ }
133
+ }
134
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":";AAEA,OAAO,KAAwB,MAAM,OAAO,CAAC;AA4B7C,MAAM,OAAO,aAAa;IAChB,MAAM,CAAe;IACrB,aAAa,CAAC;IAEtB,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE;gBACP,eAAe,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE;gBAC/C,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;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KAAK,EAAE,CAAC;YAClC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YACxB,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QAED,OAAO;YACL,OAAO,EAAE,KAAK;YACd,EAAE;YACF,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;SAC/B,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,QAAqB;QACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAEO,QAAQ;QACd,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACF"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ import yargs from 'yargs';
3
+ import { hideBin } from 'yargs/helpers';
4
+ import { MCPHttpBridge } from './bridge.js';
5
+ const argv = yargs(hideBin(process.argv))
6
+ .option('endpoint', {
7
+ alias: 'e',
8
+ type: 'string',
9
+ demandOption: true,
10
+ description: 'HTTP endpoint for the MCP service'
11
+ })
12
+ .option('token', {
13
+ alias: 't',
14
+ type: 'string',
15
+ demandOption: true,
16
+ description: 'Bearer token for authentication'
17
+ })
18
+ .option('timeout', {
19
+ type: 'number',
20
+ default: 30000,
21
+ description: 'Request timeout in milliseconds'
22
+ })
23
+ .option('retries', {
24
+ type: 'number',
25
+ default: 3,
26
+ description: 'Number of retry attempts'
27
+ })
28
+ .option('verbose', {
29
+ alias: 'v',
30
+ type: 'boolean',
31
+ default: false,
32
+ description: 'Enable verbose logging'
33
+ })
34
+ .help()
35
+ .alias('help', 'h')
36
+ .example('$0 -e "https://mcp.nimbletools.dev/v1/workspaces/abc123/servers/nationalparks/mcp" -t "eyJ..."', 'Bridge to NimbleTools nationalparks service')
37
+ .parseSync();
38
+ async function main() {
39
+ try {
40
+ if (argv.verbose) {
41
+ console.error(`Starting MCP HTTP Bridge...`);
42
+ console.error(`Endpoint: ${argv.endpoint}`);
43
+ console.error(`Token: ${argv.token.substring(0, 20)}...`);
44
+ console.error(`Timeout: ${argv.timeout}ms`);
45
+ console.error(`Retries: ${argv.retries}`);
46
+ }
47
+ const bridge = new MCPHttpBridge({
48
+ endpoint: argv.endpoint,
49
+ bearerToken: argv.token,
50
+ timeout: argv.timeout || 30000,
51
+ retries: argv.retries || 3
52
+ });
53
+ await bridge.start();
54
+ }
55
+ catch (error) {
56
+ console.error('Failed to start MCP HTTP Bridge:', error);
57
+ process.exit(1);
58
+ }
59
+ }
60
+ main().catch(error => {
61
+ console.error('Unhandled error:', error);
62
+ process.exit(1);
63
+ });
64
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAU5C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE;IAClB,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;IAClB,W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B,WAAW,EAAE,IAAI,CAAC,KAAK;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,KAAK;YAC9B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC;SAC3B,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAEvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { MCPHttpBridge } from './bridge.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { MCPHttpBridge } from './bridge.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nimbletools/mcp-http-bridge",
3
+ "version": "1.0.0",
4
+ "description": "Bridge MCP stdio protocol to HTTP-based MCP services",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "mcp-http-bridge": "dist/cli.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "ts-node src/cli.ts",
13
+ "test": "jest",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "http",
20
+ "bridge",
21
+ "claude-code",
22
+ "stdio",
23
+ "json-rpc"
24
+ ],
25
+ "dependencies": {
26
+ "axios": "^1.7.9",
27
+ "yargs": "^17.7.2"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^24.0.0",
31
+ "@types/yargs": "^17.0.33",
32
+ "typescript": "^5.7.2",
33
+ "ts-node": "^10.9.2",
34
+ "jest": "^29.7.0",
35
+ "@types/jest": "^29.5.14"
36
+ },
37
+ "files": [
38
+ "dist/**/*",
39
+ "README.md",
40
+ "LICENSE"
41
+ ],
42
+ "engines": {
43
+ "node": ">=24.0.0",
44
+ "npm": ">=10.0.0"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/nimbletools/mcp-http-bridge.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/nimbletools/mcp-http-bridge/issues"
52
+ },
53
+ "homepage": "https://github.com/nimbletools/mcp-http-bridge#readme",
54
+ "license": "MIT",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ }
58
+ }