mcpstore-gateway 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.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Store Gateway
4
+ *
5
+ * A single MCP server that gives Claude Code access to ALL your installed MCPs
6
+ * from mcpclaudecode.com. Install MCPs on the website, they appear here instantly.
7
+ *
8
+ * Usage:
9
+ * npx mcpstore-gateway --api-key YOUR_API_KEY
10
+ */
11
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Store Gateway
4
+ *
5
+ * A single MCP server that gives Claude Code access to ALL your installed MCPs
6
+ * from mcpclaudecode.com. Install MCPs on the website, they appear here instantly.
7
+ *
8
+ * Usage:
9
+ * npx mcpstore-gateway --api-key YOUR_API_KEY
10
+ */
11
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
13
+ // ---------------------------------------------------------------------------
14
+ // Config
15
+ // ---------------------------------------------------------------------------
16
+ const GATEWAY_URL = process.env.MCPSTORE_GATEWAY_URL ||
17
+ "https://rshsqjofouqyhzvzezos.supabase.co/functions/v1";
18
+ function getApiKey() {
19
+ // --api-key flag
20
+ const flagIdx = process.argv.indexOf("--api-key");
21
+ if (flagIdx !== -1 && process.argv[flagIdx + 1]) {
22
+ return process.argv[flagIdx + 1];
23
+ }
24
+ // Environment variable
25
+ if (process.env.MCPSTORE_API_KEY) {
26
+ return process.env.MCPSTORE_API_KEY;
27
+ }
28
+ console.error("Error: No API key provided.\n" +
29
+ "Usage: mcpstore-gateway --api-key YOUR_KEY\n" +
30
+ " or: MCPSTORE_API_KEY=YOUR_KEY mcpstore-gateway\n\n" +
31
+ "Get your API key at https://www.mcpclaudecode.com/dashboard");
32
+ process.exit(1);
33
+ }
34
+ const API_KEY = getApiKey();
35
+ async function fetchTools() {
36
+ const res = await fetch(`${GATEWAY_URL}/gateway-tools`, {
37
+ headers: {
38
+ Authorization: `Bearer ${API_KEY}`,
39
+ "Content-Type": "application/json",
40
+ },
41
+ });
42
+ if (!res.ok) {
43
+ const body = await res.json().catch(() => ({}));
44
+ throw new Error(body.error || `Gateway error: ${res.status}`);
45
+ }
46
+ const data = (await res.json());
47
+ return data.tools || [];
48
+ }
49
+ async function callTool(toolName, args) {
50
+ const res = await fetch(`${GATEWAY_URL}/gateway-call`, {
51
+ method: "POST",
52
+ headers: {
53
+ Authorization: `Bearer ${API_KEY}`,
54
+ "Content-Type": "application/json",
55
+ },
56
+ body: JSON.stringify({ tool: toolName, arguments: args }),
57
+ });
58
+ if (!res.ok) {
59
+ const body = await res.json().catch(() => ({}));
60
+ throw new Error(body.error || `Gateway call error: ${res.status}`);
61
+ }
62
+ const data = (await res.json());
63
+ return data.result ?? data;
64
+ }
65
+ // ---------------------------------------------------------------------------
66
+ // MCP Server
67
+ // ---------------------------------------------------------------------------
68
+ const server = new McpServer({
69
+ name: "MCP Store",
70
+ version: "1.0.0",
71
+ });
72
+ // Cache tools to avoid re-fetching on every call
73
+ let toolsCache = null;
74
+ let toolsCacheTime = 0;
75
+ const CACHE_TTL_MS = 60_000; // 1 min
76
+ async function getTools() {
77
+ const now = Date.now();
78
+ if (toolsCache && now - toolsCacheTime < CACHE_TTL_MS) {
79
+ return toolsCache;
80
+ }
81
+ toolsCache = await fetchTools();
82
+ toolsCacheTime = now;
83
+ return toolsCache;
84
+ }
85
+ // Register a dynamic tool handler — we fetch tools from the gateway and
86
+ // register them all. MCP SDK requires registering tools at init time, so we
87
+ // fetch once at startup, then use the call handler to proxy dynamically.
88
+ async function registerTools() {
89
+ const tools = await getTools();
90
+ if (tools.length === 0) {
91
+ // Register a placeholder tool so the server isn't empty
92
+ server.tool("mcpstore__info", "No MCPs installed yet. Visit https://www.mcpclaudecode.com/browse to install MCPs.", {}, async () => ({
93
+ content: [
94
+ {
95
+ type: "text",
96
+ text: "You have no MCPs installed. Visit https://www.mcpclaudecode.com/browse to browse and install MCPs. They will appear here automatically!",
97
+ },
98
+ ],
99
+ }));
100
+ return;
101
+ }
102
+ for (const tool of tools) {
103
+ // Build the input schema shape for the MCP SDK
104
+ const shape = {};
105
+ const schema = tool.inputSchema;
106
+ if (schema?.properties) {
107
+ // We pass through the raw JSON Schema — the SDK accepts it
108
+ for (const [key, value] of Object.entries(schema.properties)) {
109
+ shape[key] = value;
110
+ }
111
+ }
112
+ server.tool(tool.name, tool.description,
113
+ // Pass the raw JSON Schema as-is; the SDK will use it for validation
114
+ shape, async (args) => {
115
+ try {
116
+ const result = await callTool(tool.name, args);
117
+ const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
118
+ return {
119
+ content: [{ type: "text", text }],
120
+ };
121
+ }
122
+ catch (err) {
123
+ return {
124
+ content: [
125
+ {
126
+ type: "text",
127
+ text: `Error: ${err.message}`,
128
+ },
129
+ ],
130
+ isError: true,
131
+ };
132
+ }
133
+ });
134
+ }
135
+ }
136
+ // ---------------------------------------------------------------------------
137
+ // Main
138
+ // ---------------------------------------------------------------------------
139
+ async function main() {
140
+ try {
141
+ await registerTools();
142
+ }
143
+ catch (err) {
144
+ console.error("Failed to fetch tools from MCP Store:", err.message);
145
+ console.error("Make sure your API key is valid and you have MCPs installed at https://www.mcpclaudecode.com/browse");
146
+ // Still start the server with an error tool
147
+ server.tool("mcpstore__error", "MCP Store connection error", {}, async () => ({
148
+ content: [
149
+ {
150
+ type: "text",
151
+ text: `Failed to connect to MCP Store: ${err.message}\n\nPlease check your API key and try again.`,
152
+ },
153
+ ],
154
+ isError: true,
155
+ }));
156
+ }
157
+ const transport = new StdioServerTransport();
158
+ await server.connect(transport);
159
+ }
160
+ main();
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "mcpstore-gateway",
3
+ "version": "1.0.0",
4
+ "description": "MCP Store Gateway — One MCP server for all your installed MCPs from mcpclaudecode.com",
5
+ "keywords": ["mcp", "claude", "claude-code", "ai", "gateway", "marketplace"],
6
+ "license": "MIT",
7
+ "author": "MCP Store <contact@mcpclaudecode.com>",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/tanguyors/AIBRAIN_MCP"
11
+ },
12
+ "type": "module",
13
+ "bin": {
14
+ "mcpstore-gateway": "./dist/index.js"
15
+ },
16
+ "files": ["dist"],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsx src/index.ts",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.12.1"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^5.7.0",
27
+ "tsx": "^4.19.0",
28
+ "@types/node": "^22.0.0"
29
+ }
30
+ }