@toolguard/mcp-proxy 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/dist/cli.d.ts +18 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +67 -0
- package/dist/cli.js.map +1 -0
- package/dist/gateway.d.ts +45 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +234 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ToolGuard MCP Gateway CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* toolguard-mcp --config <config.json> -- <command> [args...]
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* toolguard-mcp --config toolguard.json -- npx @modelcontextprotocol/server-slack
|
|
10
|
+
*
|
|
11
|
+
* The gateway wraps any MCP server and enforces ToolGuard authorization on
|
|
12
|
+
* every tool call before forwarding to the upstream server.
|
|
13
|
+
*
|
|
14
|
+
* Environment variables:
|
|
15
|
+
* TOOLGUARD_API_KEY — ToolGuard API key (preferred over config file)
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ToolGuard MCP Gateway CLI
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* toolguard-mcp --config <config.json> -- <command> [args...]
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* toolguard-mcp --config toolguard.json -- npx @modelcontextprotocol/server-slack
|
|
10
|
+
*
|
|
11
|
+
* The gateway wraps any MCP server and enforces ToolGuard authorization on
|
|
12
|
+
* every tool call before forwarding to the upstream server.
|
|
13
|
+
*
|
|
14
|
+
* Environment variables:
|
|
15
|
+
* TOOLGUARD_API_KEY — ToolGuard API key (preferred over config file)
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import { ToolGuardGateway } from "./gateway.js";
|
|
19
|
+
function usage() {
|
|
20
|
+
console.error("Usage: toolguard-mcp --config <config.json> -- <command> [args...]");
|
|
21
|
+
console.error("");
|
|
22
|
+
console.error("Example:");
|
|
23
|
+
console.error(" toolguard-mcp --config toolguard.json -- npx @modelcontextprotocol/server-slack");
|
|
24
|
+
console.error("");
|
|
25
|
+
console.error("Environment variables:");
|
|
26
|
+
console.error(" TOOLGUARD_API_KEY — ToolGuard API key (preferred over config file)");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
const args = process.argv.slice(2);
|
|
30
|
+
const configIdx = args.indexOf("--config");
|
|
31
|
+
const separatorIdx = args.indexOf("--");
|
|
32
|
+
if (configIdx === -1 || separatorIdx === -1 || separatorIdx <= configIdx + 1) {
|
|
33
|
+
usage();
|
|
34
|
+
}
|
|
35
|
+
const configPath = args[configIdx + 1];
|
|
36
|
+
if (!configPath)
|
|
37
|
+
usage();
|
|
38
|
+
const upstreamCommand = args[separatorIdx + 1];
|
|
39
|
+
if (!upstreamCommand)
|
|
40
|
+
usage();
|
|
41
|
+
const upstreamArgs = args.slice(separatorIdx + 2);
|
|
42
|
+
// Load config
|
|
43
|
+
let config;
|
|
44
|
+
try {
|
|
45
|
+
config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.error(`Failed to read config file ${configPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
// Start gateway
|
|
52
|
+
const gateway = new ToolGuardGateway(config, {
|
|
53
|
+
command: upstreamCommand,
|
|
54
|
+
args: upstreamArgs,
|
|
55
|
+
});
|
|
56
|
+
gateway.start().catch((err) => {
|
|
57
|
+
console.error(`Gateway failed to start: ${err instanceof Error ? err.message : String(err)}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
});
|
|
60
|
+
// Graceful shutdown
|
|
61
|
+
process.on("SIGINT", () => {
|
|
62
|
+
gateway.close().then(() => process.exit(0));
|
|
63
|
+
});
|
|
64
|
+
process.on("SIGTERM", () => {
|
|
65
|
+
gateway.close().then(() => process.exit(0));
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,SAAS,KAAK;IACZ,OAAO,CAAC,KAAK,CACX,oEAAoE,CACrE,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,CAAC,KAAK,CACX,mFAAmF,CACpF,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACxC,OAAO,CAAC,KAAK,CACX,uEAAuE,CACxE,CAAC;IACF,OAAO,CAAC,I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AE,YAAY;CACnB,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,4BAA4B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,oBAAoB;AACpB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolGuard MCP Gateway
|
|
3
|
+
*
|
|
4
|
+
* A transparent proxy between an MCP client and an upstream MCP server.
|
|
5
|
+
* All MCP methods are passed through unchanged EXCEPT `tools/call`, which
|
|
6
|
+
* is intercepted and authorized through ToolGuard's policy engine.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* [MCP Client] <--stdio--> [ToolGuard Gateway] <--stdio--> [Upstream MCP Server]
|
|
10
|
+
*/
|
|
11
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
12
|
+
import { ToolGuard } from "@toolguard/client";
|
|
13
|
+
import type { GatewayConfig, UpstreamConfig } from "./types.js";
|
|
14
|
+
export interface GatewayOptions {
|
|
15
|
+
/** Inject a pre-configured ToolGuard client (skips env var check). For testing. */
|
|
16
|
+
toolguardClient?: ToolGuard;
|
|
17
|
+
}
|
|
18
|
+
export interface StartOptions {
|
|
19
|
+
/** Override the upstream transport (default: StdioClientTransport from upstreamConfig). */
|
|
20
|
+
upstreamTransport?: Transport;
|
|
21
|
+
/** Override the client-facing transport (default: StdioServerTransport on stdin/stdout). */
|
|
22
|
+
clientTransport?: Transport;
|
|
23
|
+
}
|
|
24
|
+
export declare class ToolGuardGateway {
|
|
25
|
+
private upstream;
|
|
26
|
+
private proxy;
|
|
27
|
+
private tg;
|
|
28
|
+
private sessionId;
|
|
29
|
+
private config;
|
|
30
|
+
private upstreamConfig;
|
|
31
|
+
constructor(config: GatewayConfig, upstreamConfig: UpstreamConfig, options?: GatewayOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Start the gateway:
|
|
34
|
+
* 1. Connect to upstream MCP server and discover its capabilities
|
|
35
|
+
* 2. Create a proxy Server advertising those same capabilities
|
|
36
|
+
* 3. Wire up passthrough + authorization handlers
|
|
37
|
+
* 4. Connect the proxy to the client-facing transport
|
|
38
|
+
*/
|
|
39
|
+
start(options?: StartOptions): Promise<void>;
|
|
40
|
+
/** Shut down both connections cleanly. */
|
|
41
|
+
close(): Promise<void>;
|
|
42
|
+
private registerHandlers;
|
|
43
|
+
private handleToolCall;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkBH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,4FAA4F;IAC5F,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,cAAc,CAAiB;gBAGrC,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,cAAc,EAC9B,OAAO,CAAC,EAAE,cAAc;IA4B1B;;;;;;OAMG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAsElD,0CAA0C;IACpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B,OAAO,CAAC,gBAAgB;YAwEV,cAAc;CA+E7B"}
|
package/dist/gateway.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolGuard MCP Gateway
|
|
3
|
+
*
|
|
4
|
+
* A transparent proxy between an MCP client and an upstream MCP server.
|
|
5
|
+
* All MCP methods are passed through unchanged EXCEPT `tools/call`, which
|
|
6
|
+
* is intercepted and authorized through ToolGuard's policy engine.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* [MCP Client] <--stdio--> [ToolGuard Gateway] <--stdio--> [Upstream MCP Server]
|
|
10
|
+
*/
|
|
11
|
+
import { Server } from "@modelcontextprotocol/sdk/server";
|
|
12
|
+
import { Client } from "@modelcontextprotocol/sdk/client";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
15
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, CompleteRequestSchema, SetLevelRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
16
|
+
import { ToolGuard } from "@toolguard/client";
|
|
17
|
+
export class ToolGuardGateway {
|
|
18
|
+
upstream;
|
|
19
|
+
proxy;
|
|
20
|
+
tg;
|
|
21
|
+
sessionId;
|
|
22
|
+
config;
|
|
23
|
+
upstreamConfig;
|
|
24
|
+
constructor(config, upstreamConfig, options) {
|
|
25
|
+
this.config = config;
|
|
26
|
+
this.upstreamConfig = upstreamConfig;
|
|
27
|
+
if (options?.toolguardClient) {
|
|
28
|
+
this.tg = options.toolguardClient;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const apiKey = process.env.TOOLGUARD_API_KEY;
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
throw new Error("TOOLGUARD_API_KEY environment variable is required.");
|
|
34
|
+
}
|
|
35
|
+
this.tg = new ToolGuard({
|
|
36
|
+
apiKey,
|
|
37
|
+
baseUrl: config.toolguard.baseUrl,
|
|
38
|
+
orgId: config.toolguard.orgId,
|
|
39
|
+
agentId: config.toolguard.agentId,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Placeholders — initialized in start() after upstream capabilities are known
|
|
43
|
+
this.upstream = null;
|
|
44
|
+
this.proxy = null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Start the gateway:
|
|
48
|
+
* 1. Connect to upstream MCP server and discover its capabilities
|
|
49
|
+
* 2. Create a proxy Server advertising those same capabilities
|
|
50
|
+
* 3. Wire up passthrough + authorization handlers
|
|
51
|
+
* 4. Connect the proxy to the client-facing transport
|
|
52
|
+
*/
|
|
53
|
+
async start(options) {
|
|
54
|
+
// 1. Connect to upstream
|
|
55
|
+
this.upstream = new Client({ name: "toolguard-gateway", version: "0.1.0" }, {});
|
|
56
|
+
const upstreamTransport = options?.upstreamTransport ??
|
|
57
|
+
new StdioClientTransport({
|
|
58
|
+
command: this.upstreamConfig.command,
|
|
59
|
+
args: this.upstreamConfig.args,
|
|
60
|
+
env: this.upstreamConfig.env
|
|
61
|
+
? { ...process.env, ...this.upstreamConfig.env }
|
|
62
|
+
: undefined,
|
|
63
|
+
stderr: "inherit",
|
|
64
|
+
});
|
|
65
|
+
await this.upstream.connect(upstreamTransport);
|
|
66
|
+
// 2. Mirror upstream capabilities
|
|
67
|
+
const upstreamCaps = this.upstream.getServerCapabilities() ?? {};
|
|
68
|
+
const capabilities = {};
|
|
69
|
+
if (upstreamCaps.tools) {
|
|
70
|
+
capabilities.tools = { listChanged: !!upstreamCaps.tools.listChanged };
|
|
71
|
+
}
|
|
72
|
+
if (upstreamCaps.resources) {
|
|
73
|
+
capabilities.resources = {
|
|
74
|
+
subscribe: !!upstreamCaps.resources.subscribe,
|
|
75
|
+
listChanged: !!upstreamCaps.resources.listChanged,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (upstreamCaps.prompts) {
|
|
79
|
+
capabilities.prompts = {
|
|
80
|
+
listChanged: !!upstreamCaps.prompts.listChanged,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (upstreamCaps.logging) {
|
|
84
|
+
capabilities.logging = upstreamCaps.logging;
|
|
85
|
+
}
|
|
86
|
+
if (upstreamCaps.completions) {
|
|
87
|
+
capabilities.completions = upstreamCaps.completions;
|
|
88
|
+
}
|
|
89
|
+
// 3. Create proxy server
|
|
90
|
+
const upstreamInfo = this.upstream.getServerVersion();
|
|
91
|
+
const serverName = upstreamInfo
|
|
92
|
+
? `toolguard → ${upstreamInfo.name}`
|
|
93
|
+
: "toolguard-gateway";
|
|
94
|
+
this.proxy = new Server({ name: serverName, version: "0.1.0" }, {
|
|
95
|
+
capabilities,
|
|
96
|
+
instructions: this.upstream.getInstructions(),
|
|
97
|
+
});
|
|
98
|
+
// 4. Wire handlers
|
|
99
|
+
this.registerHandlers(upstreamCaps);
|
|
100
|
+
// 5. Connect to client-facing transport
|
|
101
|
+
const clientTransport = options?.clientTransport ?? new StdioServerTransport();
|
|
102
|
+
await this.proxy.connect(clientTransport);
|
|
103
|
+
}
|
|
104
|
+
/** Shut down both connections cleanly. */
|
|
105
|
+
async close() {
|
|
106
|
+
await this.proxy?.close();
|
|
107
|
+
await this.upstream?.close();
|
|
108
|
+
}
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Handler registration
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
registerHandlers(caps) {
|
|
113
|
+
// --- Tools (always register if upstream supports) ---
|
|
114
|
+
if (caps.tools) {
|
|
115
|
+
this.proxy.setRequestHandler(ListToolsRequestSchema, async (request) => {
|
|
116
|
+
return this.upstream.listTools(request.params);
|
|
117
|
+
});
|
|
118
|
+
this.proxy.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
119
|
+
return this.handleToolCall(request.params);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// --- Resources passthrough ---
|
|
123
|
+
if (caps.resources) {
|
|
124
|
+
this.proxy.setRequestHandler(ListResourcesRequestSchema, async (request) => {
|
|
125
|
+
return this.upstream.listResources(request.params);
|
|
126
|
+
});
|
|
127
|
+
this.proxy.setRequestHandler(ListResourceTemplatesRequestSchema, async (request) => {
|
|
128
|
+
return this.upstream.listResourceTemplates(request.params);
|
|
129
|
+
});
|
|
130
|
+
this.proxy.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
131
|
+
return this.upstream.readResource(request.params);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// --- Prompts passthrough ---
|
|
135
|
+
if (caps.prompts) {
|
|
136
|
+
this.proxy.setRequestHandler(ListPromptsRequestSchema, async (request) => {
|
|
137
|
+
return this.upstream.listPrompts(request.params);
|
|
138
|
+
});
|
|
139
|
+
this.proxy.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
140
|
+
return this.upstream.getPrompt(request.params);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// --- Completions passthrough ---
|
|
144
|
+
if (caps.completions) {
|
|
145
|
+
this.proxy.setRequestHandler(CompleteRequestSchema, async (request) => {
|
|
146
|
+
return this.upstream.complete(request.params);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// --- Logging passthrough ---
|
|
150
|
+
if (caps.logging) {
|
|
151
|
+
this.proxy.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
152
|
+
return this.upstream.setLoggingLevel(request.params.level);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// Tool call authorization gate
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
async handleToolCall(params) {
|
|
160
|
+
const mcpToolName = params.name;
|
|
161
|
+
const toolguardName = this.config.toolMapping?.[mcpToolName] ?? mcpToolName;
|
|
162
|
+
// Lazy session creation
|
|
163
|
+
if (!this.sessionId) {
|
|
164
|
+
try {
|
|
165
|
+
const session = await this.tg.createSession({
|
|
166
|
+
environment: this.config.session.environment,
|
|
167
|
+
scopes: this.config.session.scopes,
|
|
168
|
+
userId: this.config.session.userId,
|
|
169
|
+
});
|
|
170
|
+
this.sessionId = session.id;
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
return {
|
|
174
|
+
content: [
|
|
175
|
+
{
|
|
176
|
+
type: "text",
|
|
177
|
+
text: `ToolGuard session creation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
isError: true,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Authorize through ToolGuard
|
|
185
|
+
let decision;
|
|
186
|
+
try {
|
|
187
|
+
decision = await this.tg.authorize({
|
|
188
|
+
sessionId: this.sessionId,
|
|
189
|
+
tool: { name: toolguardName },
|
|
190
|
+
context: {},
|
|
191
|
+
payloadSummary: params.arguments ?? {},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
return {
|
|
196
|
+
content: [
|
|
197
|
+
{
|
|
198
|
+
type: "text",
|
|
199
|
+
text: `ToolGuard authorization failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
isError: true,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// Denied
|
|
206
|
+
if (decision.decision === "deny") {
|
|
207
|
+
const reasons = decision.reasonCodes.join(", ");
|
|
208
|
+
return {
|
|
209
|
+
content: [
|
|
210
|
+
{
|
|
211
|
+
type: "text",
|
|
212
|
+
text: `Tool call denied by policy. Reasons: ${reasons}`,
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
isError: true,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// Requires approval
|
|
219
|
+
if (decision.decision === "require_approval") {
|
|
220
|
+
return {
|
|
221
|
+
content: [
|
|
222
|
+
{
|
|
223
|
+
type: "text",
|
|
224
|
+
text: `Tool call requires human approval (approval ID: ${decision.approvalId}). The request has been queued — contact your administrator to approve it.`,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
isError: true,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
// Allowed — forward to upstream
|
|
231
|
+
return this.upstream.callTool(params);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAA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;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,wCAAwC,OAAO,EAAE;qBACxD;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,oBAAoB;QACpB,IAAI,QAAQ,CAAC,QAAQ,KAAK,kBAAkB,EAAE,CAAC;YAC7C,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,mDAAmD,QAAQ,CAAC,UAAU,4EAA4E;qBACzJ;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,gCAAgC;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the ToolGuard MCP Gateway.
|
|
3
|
+
*
|
|
4
|
+
* The gateway sits between an MCP client (e.g. Claude, Cursor) and an upstream
|
|
5
|
+
* MCP server, intercepting every `tools/call` and routing it through ToolGuard's
|
|
6
|
+
* policy engine before forwarding to the upstream server.
|
|
7
|
+
*/
|
|
8
|
+
export interface GatewayConfig {
|
|
9
|
+
/** ToolGuard API connection. API key must be set via TOOLGUARD_API_KEY env var. */
|
|
10
|
+
toolguard: {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
orgId: string;
|
|
13
|
+
agentId: string;
|
|
14
|
+
};
|
|
15
|
+
/** Session parameters for ToolGuard authorization. */
|
|
16
|
+
session: {
|
|
17
|
+
environment: string;
|
|
18
|
+
scopes: string[];
|
|
19
|
+
userId?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Maps MCP tool names to ToolGuard catalog names.
|
|
23
|
+
* If a tool is not listed here, the MCP name is used as-is.
|
|
24
|
+
*
|
|
25
|
+
* Example: { "read_file": "filesystem.read", "run_command": "shell.execute" }
|
|
26
|
+
*/
|
|
27
|
+
toolMapping?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
/** Upstream MCP server spawn configuration. */
|
|
30
|
+
export interface UpstreamConfig {
|
|
31
|
+
command: string;
|
|
32
|
+
args?: string[];
|
|
33
|
+
env?: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,aAAa;IAC5B,mFAAmF;IACnF,SAAS,EAAE;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF,sDAAsD;IACtD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the ToolGuard MCP Gateway.
|
|
3
|
+
*
|
|
4
|
+
* The gateway sits between an MCP client (e.g. Claude, Cursor) and an upstream
|
|
5
|
+
* MCP server, intercepting every `tools/call` and routing it through ToolGuard's
|
|
6
|
+
* policy engine before forwarding to the upstream server.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toolguard/mcp-proxy",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP gateway proxy that enforces ToolGuard authorization on every tool call",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"toolguard-mcp": "./dist/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "vitest run"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
23
|
+
"@toolguard/client": "^0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"files": ["dist"],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/vishutdhar/toolguard.git",
|
|
29
|
+
"directory": "packages/mcp-proxy"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/vishutdhar/toolguard/tree/master/packages/mcp-proxy",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^25.3.5",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^4.0.18"
|
|
40
|
+
}
|
|
41
|
+
}
|