@mcphero/mcp 1.1.6 → 1.2.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/.turbo/turbo-build.log +17 -18
- package/.turbo/turbo-check.log +3 -3
- package/.turbo/turbo-prepack.log +8 -8
- package/README.md +91 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +78 -5
- package/build/index.js.map +1 -1
- package/package.json +4 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
DTS Build
|
|
17
|
-
DTS
|
|
18
|
-
DTS build/index.d.ts 521.00 B
|
|
1
|
+
|
|
2
|
+
> @mcphero/mcp@1.1.7 build /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Using tsup config: /Users/atomic/projects/ai/mcphero/packages/mcp/tsup.config.ts
|
|
9
|
+
CLI Target: es2022
|
|
10
|
+
CLI Cleaning output folder
|
|
11
|
+
ESM Build start
|
|
12
|
+
ESM build/index.js 16.84 KB
|
|
13
|
+
ESM build/index.js.map 29.10 KB
|
|
14
|
+
ESM ⚡️ Build success in 9ms
|
|
15
|
+
DTS Build start
|
|
16
|
+
DTS ⚡️ Build success in 827ms
|
|
17
|
+
DTS build/index.d.ts 588.00 B
|
package/.turbo/turbo-check.log
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
> @mcphero/mcp@1.1.
|
|
2
|
+
> @mcphero/mcp@1.1.7 check /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
3
3
|
> pnpm lint && pnpm typecheck
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @mcphero/mcp@1.1.
|
|
6
|
+
> @mcphero/mcp@1.1.7 lint /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
7
7
|
> eslint
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @mcphero/mcp@1.1.
|
|
10
|
+
> @mcphero/mcp@1.1.7 typecheck /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
11
11
|
> tsc --noEmit
|
|
12
12
|
|
package/.turbo/turbo-prepack.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @mcphero/mcp@1.1.
|
|
3
|
+
> @mcphero/mcp@1.1.7 prepack /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
4
4
|
> pnpm clean && pnpm build
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @mcphero/mcp@1.1.
|
|
7
|
+
> @mcphero/mcp@1.1.7 clean /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
8
8
|
> rimraf build
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
> @mcphero/mcp@1.1.
|
|
11
|
+
> @mcphero/mcp@1.1.7 build /Users/atomic/projects/ai/mcphero/packages/mcp
|
|
12
12
|
> tsup
|
|
13
13
|
|
|
14
14
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
[34mCLI[39m Target: es2022
|
|
19
19
|
[34mCLI[39m Cleaning output folder
|
|
20
20
|
[34mESM[39m Build start
|
|
21
|
-
[32mESM[39m [1mbuild/index.js [22m[
|
|
22
|
-
[32mESM[39m [1mbuild/index.js.map [22m[
|
|
23
|
-
[32mESM[39m ⚡️ Build success in
|
|
21
|
+
[32mESM[39m [1mbuild/index.js [22m[32m16.84 KB[39m
|
|
22
|
+
[32mESM[39m [1mbuild/index.js.map [22m[32m29.10 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 11ms
|
|
24
24
|
DTS Build start
|
|
25
|
-
DTS ⚡️ Build success in
|
|
26
|
-
DTS build/index.d.ts
|
|
25
|
+
DTS ⚡️ Build success in 853ms
|
|
26
|
+
DTS build/index.d.ts 588.00 B
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @mcphero/mcp
|
|
2
|
+
|
|
3
|
+
MCP transport adapters for [MCPHero](https://github.com/atomicbi/mcphero) — expose your actions as MCP tools over stdio, Streamable HTTP, or via a CLI proxy client.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @mcphero/core @mcphero/mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Adapters
|
|
12
|
+
|
|
13
|
+
### stdio
|
|
14
|
+
|
|
15
|
+
Standard MCP transport for local tool servers. Communicates over stdin/stdout.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { mcphero } from '@mcphero/core'
|
|
19
|
+
import { stdio } from '@mcphero/mcp'
|
|
20
|
+
|
|
21
|
+
await mcphero({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
22
|
+
.adapter(stdio())
|
|
23
|
+
.action(MyAction)
|
|
24
|
+
.start()
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Configure in Claude Desktop or Claude Code:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"my-tools": {
|
|
33
|
+
"command": "node",
|
|
34
|
+
"args": ["server.js"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### http
|
|
41
|
+
|
|
42
|
+
Session-based MCP transport over HTTP with SSE streaming and resumability.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { mcphero } from '@mcphero/core'
|
|
46
|
+
import { http } from '@mcphero/mcp'
|
|
47
|
+
|
|
48
|
+
await mcphero({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
49
|
+
.adapter(http({ host: 'localhost', port: 8080, allowedHosts: ['localhost'] }))
|
|
50
|
+
.action(MyAction)
|
|
51
|
+
.start()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Exposes `POST /mcp` (invoke tools), `GET /mcp` (SSE stream), and `DELETE /mcp` (terminate session). Built on Express with `StreamableHTTPServerTransport` from the MCP SDK.
|
|
55
|
+
|
|
56
|
+
| Option | Type | Description |
|
|
57
|
+
|--------|------|-------------|
|
|
58
|
+
| `host` | `string` | Bind address |
|
|
59
|
+
| `port` | `number` | Listen port |
|
|
60
|
+
| `allowedHosts` | `string[]` | Allowed hosts for DNS rebinding protection |
|
|
61
|
+
|
|
62
|
+
### cliProxy
|
|
63
|
+
|
|
64
|
+
MCP CLI proxy client — connects to a running HTTP MCP server and invokes tools from the command line.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { mcphero } from '@mcphero/core'
|
|
68
|
+
import { cliProxy } from '@mcphero/mcp'
|
|
69
|
+
|
|
70
|
+
await mcphero({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
71
|
+
.adapter(cliProxy({ url: 'http://localhost:8080/mcp' }))
|
|
72
|
+
.start()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## How Actions Become MCP Tools
|
|
76
|
+
|
|
77
|
+
| Action property | MCP tool property |
|
|
78
|
+
|-----------------|-------------------|
|
|
79
|
+
| `name: 'searchDocs'` | Tool name: `SearchDocs` (PascalCase) |
|
|
80
|
+
| `description` | Tool description |
|
|
81
|
+
| `input` (Zod schema) | `inputSchema` (JSON Schema) |
|
|
82
|
+
| Return value | `TextContent` JSON response |
|
|
83
|
+
| Thrown errors | Structured error response |
|
|
84
|
+
|
|
85
|
+
Logging notifications (`logger.info()`, `logger.progress()`) are sent to the MCP client as `notifications/message` and `notifications/progress`.
|
|
86
|
+
|
|
87
|
+
## See Also
|
|
88
|
+
|
|
89
|
+
- [MCPHero README](https://github.com/atomicbi/mcphero) — Full documentation
|
|
90
|
+
- [`@mcphero/core`](https://www.npmjs.com/package/@mcphero/core) — Core library
|
|
91
|
+
- [`@mcphero/vercel`](https://www.npmjs.com/package/@mcphero/vercel) — Stateless MCP for Vercel
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AdapterFactory } from '@mcphero/core';
|
|
2
|
+
import { AuthConfig } from '@mcphero/auth';
|
|
2
3
|
import { CreateMcpExpressAppOptions } from '@modelcontextprotocol/sdk/server/express.js';
|
|
3
4
|
|
|
4
5
|
interface CliProxyOptions {
|
|
@@ -9,6 +10,7 @@ declare const cliProxy: AdapterFactory<CliProxyOptions>;
|
|
|
9
10
|
interface HttpAdapterOptions extends CreateMcpExpressAppOptions {
|
|
10
11
|
host: string;
|
|
11
12
|
port: number;
|
|
13
|
+
auth?: AuthConfig;
|
|
12
14
|
}
|
|
13
15
|
declare const http: AdapterFactory<HttpAdapterOptions>;
|
|
14
16
|
|
package/build/index.js
CHANGED
|
@@ -84,6 +84,7 @@ var cliProxy = ({ url }) => {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
// src/adapter/http.ts
|
|
87
|
+
import { generateProtectedResourceMetadata, validateToken } from "@mcphero/auth";
|
|
87
88
|
import { toolResponse } from "@mcphero/core";
|
|
88
89
|
import { createLogger } from "@mcphero/logger";
|
|
89
90
|
import { InMemoryEventStore } from "@modelcontextprotocol/sdk/examples/shared/inMemoryEventStore.js";
|
|
@@ -94,12 +95,83 @@ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
|
94
95
|
import { capitalCase, pascalCase } from "change-case";
|
|
95
96
|
import cors from "cors";
|
|
96
97
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
98
|
+
import express from "express";
|
|
97
99
|
import { readFile } from "fs/promises";
|
|
98
|
-
|
|
100
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
101
|
+
var authStorage = new AsyncLocalStorage();
|
|
102
|
+
var http = ({ host, port, auth, ...mcpOptions }) => {
|
|
99
103
|
return (options, baseContext) => {
|
|
100
104
|
const context = baseContext.fork({ adapter: "http" });
|
|
101
105
|
const app = createMcpExpressApp({ ...mcpOptions, host });
|
|
102
106
|
app.use(cors({ exposedHeaders: ["WWW-Authenticate", "Mcp-Session-Id", "Last-Event-Id", "Mcp-Protocol-Version"], origin: "*" }));
|
|
107
|
+
if (auth?.authorizationServers?.length && auth.resourceUrl) {
|
|
108
|
+
app.get("/.well-known/oauth-protected-resource", (_req, res) => {
|
|
109
|
+
const metadata = generateProtectedResourceMetadata(auth.resourceUrl, auth.authorizationServers);
|
|
110
|
+
res.json(metadata);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const oauthPaths = /* @__PURE__ */ new Set();
|
|
114
|
+
if (auth?.provider) {
|
|
115
|
+
const provider = auth.provider;
|
|
116
|
+
const toOAuthReq = (req) => ({
|
|
117
|
+
method: req.method,
|
|
118
|
+
url: new URL(req.url, `${req.protocol}://${req.get("host")}`),
|
|
119
|
+
headers: Object.fromEntries(Object.entries(req.headers).map(([k, v]) => [k, Array.isArray(v) ? v[0] : v])),
|
|
120
|
+
body: req.body
|
|
121
|
+
});
|
|
122
|
+
const sendOAuth = (res, oauthRes) => {
|
|
123
|
+
for (const [key, value] of Object.entries(oauthRes.headers)) {
|
|
124
|
+
res.header(key, value);
|
|
125
|
+
}
|
|
126
|
+
if (oauthRes.body) {
|
|
127
|
+
res.status(oauthRes.status).send(typeof oauthRes.body === "string" ? oauthRes.body : JSON.stringify(oauthRes.body));
|
|
128
|
+
} else {
|
|
129
|
+
res.status(oauthRes.status).end();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
oauthPaths.add("/.well-known/oauth-authorization-server");
|
|
133
|
+
oauthPaths.add("/authorize");
|
|
134
|
+
oauthPaths.add("/auth/callback");
|
|
135
|
+
oauthPaths.add("/token");
|
|
136
|
+
oauthPaths.add("/register");
|
|
137
|
+
app.get("/.well-known/oauth-authorization-server", (_req, res) => {
|
|
138
|
+
sendOAuth(res, provider.metadata());
|
|
139
|
+
});
|
|
140
|
+
app.get("/authorize", async (req, res) => {
|
|
141
|
+
sendOAuth(res, await provider.authorize(toOAuthReq(req)));
|
|
142
|
+
});
|
|
143
|
+
app.get("/auth/callback", async (req, res) => {
|
|
144
|
+
sendOAuth(res, await provider.callback(toOAuthReq(req)));
|
|
145
|
+
});
|
|
146
|
+
app.post("/token", express.urlencoded({ extended: false }), async (req, res) => {
|
|
147
|
+
sendOAuth(res, await provider.token(toOAuthReq(req)));
|
|
148
|
+
});
|
|
149
|
+
app.post("/register", express.json(), async (req, res) => {
|
|
150
|
+
sendOAuth(res, await provider.register(toOAuthReq(req)));
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (auth) {
|
|
154
|
+
app.use(async (req, res, next) => {
|
|
155
|
+
if (req.path.startsWith("/.well-known/") || oauthPaths.has(req.path)) {
|
|
156
|
+
return next();
|
|
157
|
+
}
|
|
158
|
+
const result = await validateToken(req.headers.authorization, auth);
|
|
159
|
+
if (result.error) {
|
|
160
|
+
for (const [key, value] of Object.entries(result.error.headers)) {
|
|
161
|
+
res.header(key, value);
|
|
162
|
+
}
|
|
163
|
+
res.status(result.error.statusCode).json(result.error.body);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (result.auth) {
|
|
167
|
+
authStorage.run(result.auth, () => {
|
|
168
|
+
next();
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
next();
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
103
175
|
const transports = {};
|
|
104
176
|
let mountedActions = [];
|
|
105
177
|
const createServer = () => {
|
|
@@ -136,7 +208,8 @@ var http = ({ host, port, ...mcpOptions }) => {
|
|
|
136
208
|
});
|
|
137
209
|
}
|
|
138
210
|
});
|
|
139
|
-
|
|
211
|
+
const currentAuth = authStorage.getStore();
|
|
212
|
+
return action.run(input, context.fork({ logger, extra, ...currentAuth ? { auth: currentAuth } : {} })).then((result) => {
|
|
140
213
|
return toolResponse(result);
|
|
141
214
|
}).catch((error) => {
|
|
142
215
|
if (error instanceof Error) {
|
|
@@ -166,7 +239,7 @@ var http = ({ host, port, ...mcpOptions }) => {
|
|
|
166
239
|
let transport;
|
|
167
240
|
if (sessionId && transports[sessionId]) {
|
|
168
241
|
transport = transports[sessionId];
|
|
169
|
-
} else if (
|
|
242
|
+
} else if (isInitializeRequest(req.body)) {
|
|
170
243
|
const eventStore = new InMemoryEventStore();
|
|
171
244
|
transport = new StreamableHTTPServerTransport({
|
|
172
245
|
sessionIdGenerator: () => randomUUID2(),
|
|
@@ -191,9 +264,9 @@ var http = ({ host, port, ...mcpOptions }) => {
|
|
|
191
264
|
await transport.handleRequest(req, res, req.body);
|
|
192
265
|
return;
|
|
193
266
|
} else {
|
|
194
|
-
res.status(
|
|
267
|
+
res.status(404).json({
|
|
195
268
|
jsonrpc: "2.0",
|
|
196
|
-
error: { code: -32e3, message: "
|
|
269
|
+
error: { code: -32e3, message: "Session not found" },
|
|
197
270
|
id: null
|
|
198
271
|
});
|
|
199
272
|
return;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter/cliProxy.ts","../src/adapter/http.ts","../src/adapter/stdio.ts"],"sourcesContent":["import { intro } from '@clack/prompts'\nimport { AdapterFactory, parseToolResponse, ToolResponse, unwrap } from '@mcphero/core'\nimport { createCLILogger } from '@mcphero/logger'\nimport { Client } from '@modelcontextprotocol/sdk/client'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'\nimport { LoggingMessageNotificationSchema, ProgressNotificationSchema } from '@modelcontextprotocol/sdk/types'\nimport { kebabCase } from 'change-case'\nimport { Command } from 'commander'\nimport { randomUUID } from 'crypto'\nimport { z } from 'zod'\nimport { JSONSchema } from 'zod/v4/core'\n\nexport interface CliProxyOptions {\n url: URL\n}\n\nexport const cliProxy: AdapterFactory<CliProxyOptions> = ({ url }) => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'cliProxy' })\n const program = new Command()\n .name(options.name)\n .description(options.description)\n .version(options.version)\n .option('-s, --silent', 'Silent mode, prevent log messages', false)\n\n return {\n context,\n start: async () => {\n const client = new Client({\n name: options.name,\n description: options.description,\n version: options.version\n })\n const transport = new StreamableHTTPClientTransport(url)\n await client.connect(transport)\n const { tools } = await client.listTools()\n for (const tool of tools) {\n const name = kebabCase(tool.name)\n const command = program.command(name)\n if (tool.description) { command.description(tool.description) }\n const schema = z.fromJSONSchema(tool.inputSchema as JSONSchema.JSONSchema)\n if (!(schema instanceof z.ZodObject)) { throw new Error('Invalid schema') }\n const shape = schema.shape\n const keys = Object.keys(shape)\n for (const key of keys) {\n const [type, { defaultValue }] = unwrap(shape[key])\n const description = type.description\n if (type instanceof z.ZodBoolean) {\n command.option(`--${kebabCase(key)}`, description, defaultValue)\n command.option(`--no-${kebabCase(key)}`)\n } else if (type instanceof z.ZodNumber) {\n command.option(`--${kebabCase(key)} <number>`, description, defaultValue)\n } else if (type instanceof z.ZodString || type instanceof z.ZodEnum) {\n command.option(`--${kebabCase(key)} <string>`, description, defaultValue)\n } else if (type instanceof z.ZodObject || type instanceof z.ZodRecord || type instanceof z.ZodArray) {\n command.option(`--${kebabCase(key)} <json>`, description ?? '', JSON.parse, defaultValue)\n } else {\n throw new Error(`Invalid zod type: ${type.def.type}`)\n }\n }\n command.action(async (args) => {\n const { silent } = program.opts<{ silent: boolean }>()\n const logger = createCLILogger()\n if (!silent) {\n intro(`${options.name} - ${tool.name}`)\n client.setNotificationHandler(LoggingMessageNotificationSchema, ({ params: { level, data } }) => {\n logger[level](data)\n })\n client.setNotificationHandler(ProgressNotificationSchema, ({ params: { progress, total, message } }) => {\n logger.info({ progress, total, message })\n })\n }\n const input = await schema.parseAsync(args)\n const response = await client.callTool({\n name: tool.name,\n arguments: input,\n _meta: { progressToken: randomUUID() }\n })\n const result = parseToolResponse(response as ToolResponse)\n process.stdout.write(JSON.stringify(result, null, 2))\n })\n }\n await program.parseAsync()\n await transport.close()\n },\n stop: async () => { }\n }\n }\n}\n","import { Action, AdapterFactory, SideloadResource, toolResponse } from '@mcphero/core'\nimport { createLogger } from '@mcphero/logger'\nimport { InMemoryEventStore } from '@modelcontextprotocol/sdk/examples/shared/inMemoryEventStore.js'\nimport { createMcpExpressApp, CreateMcpExpressAppOptions } from '@modelcontextprotocol/sdk/server/express.js'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'\nimport { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js'\nimport { capitalCase, pascalCase } from 'change-case'\nimport cors from 'cors'\nimport { randomUUID } from 'crypto'\nimport { Request, Response } from 'express'\nimport { readFile } from 'fs/promises'\nimport { Server } from 'http'\n\nexport interface HttpAdapterOptions extends CreateMcpExpressAppOptions {\n host: string\n port: number\n}\n\nexport const http: AdapterFactory<HttpAdapterOptions> = ({ host, port, ...mcpOptions }) => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'http' })\n const app = createMcpExpressApp({ ...mcpOptions, host })\n app.use(cors({ exposedHeaders: ['WWW-Authenticate', 'Mcp-Session-Id', 'Last-Event-Id', 'Mcp-Protocol-Version'], origin: '*' }))\n const transports: Record<string, StreamableHTTPServerTransport> = {}\n let mountedActions: Action[] = []\n\n const createServer = () => {\n const server = new McpServer({\n name: options.name,\n description: options.description,\n version: options.version\n }, {\n capabilities: { tools: {}, logging: {} }\n })\n for (const action of mountedActions) {\n server.registerTool(pascalCase(action.name), {\n title: capitalCase(action.name),\n description: action.description,\n inputSchema: action.input\n }, async (input, extra) => {\n const logger = createLogger({\n stream: process.stderr,\n onLog: (level, data) => {\n extra.sendNotification({ method: 'notifications/message', params: { level, data } })\n },\n onProgress: ({ progress, total, message }) => {\n if (!extra._meta?.progressToken) { return }\n extra.sendNotification({\n method: 'notifications/progress',\n params: {\n progress,\n total,\n message,\n progressToken: extra._meta.progressToken\n }\n })\n }\n })\n return action.run(input, context.fork({ logger, extra })).then((result) => {\n return toolResponse(result)\n }).catch((error) => {\n if (error instanceof Error) {\n return toolResponse({ success: false, name: error.name, message: error.message, stack: error.stack })\n } else {\n return toolResponse({ success: false, name: 'Unknown Error', message: 'An unknown error occured', error })\n }\n })\n })\n }\n return server\n }\n\n app.get('/resource/:id', async (req: Request, res: Response) => {\n const id = req.params.id\n if (!id || typeof id !== 'string') { throw new Error('Invalid ID') }\n const resourceMeta: SideloadResource = JSON.parse(await readFile(`resources/${id}.json`, 'utf-8'))\n const buffer = await readFile(`resources/${id}`)\n res.status(200)\n res.header('Content-Type', resourceMeta.contentType)\n res.send(buffer)\n })\n\n app.post('/mcp', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n try {\n let transport: StreamableHTTPServerTransport\n if (sessionId && transports[sessionId]) {\n transport = transports[sessionId]\n } else if (!sessionId && isInitializeRequest(req.body)) {\n const eventStore = new InMemoryEventStore()\n transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n enableJsonResponse: false,\n eventStore,\n onsessioninitialized: (sId) => {\n console.log(`Session initialized with ID: ${sId}`)\n transports[sId] = transport\n }\n })\n transport.onerror = (error) => {\n console.error(error)\n }\n transport.onclose = () => {\n const sid = transport.sessionId\n if (sid && transports[sid]) {\n console.log(`Transport closed for session ${sid}, removing from transports map`)\n delete transports[sid]\n }\n }\n await createServer().connect(transport)\n await transport.handleRequest(req, res, req.body)\n return\n } else {\n res.status(400).json({\n jsonrpc: '2.0',\n error: { code: -32_000, message: 'Bad Request: No valid session ID provided' },\n id: null\n })\n return\n }\n\n // Handle the request with existing transport - no need to reconnect\n // The existing transport is already connected to the server\n await transport.handleRequest(req, res, req.body)\n } catch (error) {\n console.error('Error handling MCP request:', error)\n if (!res.headersSent) {\n res.status(500).json({\n jsonrpc: '2.0',\n error: { code: -32_603, message: 'Internal server error' },\n id: null\n })\n }\n }\n })\n\n app.get('/mcp', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send('Invalid or missing session ID')\n return\n }\n\n // Check for Last-Event-ID header for resumability\n const lastEventId = req.headers['last-event-id'] as string | undefined\n if (lastEventId) {\n console.log(`Client reconnecting with Last-Event-ID: ${lastEventId}`)\n } else {\n console.log(`Establishing new SSE stream for session ${sessionId}`)\n }\n\n const transport = transports[sessionId]\n await transport.handleRequest(req, res)\n })\n\n app.delete('/mcp', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send('Invalid or missing session ID')\n return\n }\n\n console.log(`Received session termination request for session ${sessionId}`)\n\n try {\n const transport = transports[sessionId]\n await transport.handleRequest(req, res)\n } catch (error) {\n console.error('Error handling session termination:', error)\n if (!res.headersSent) {\n res.status(500).send('Error processing session termination')\n }\n }\n })\n\n app.get('/mcp/resource/:id', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send('Invalid or missing session ID')\n return\n }\n\n // Check for Last-Event-ID header for resumability\n const lastEventId = req.headers['last-event-id'] as string | undefined\n if (lastEventId) {\n console.log(`Client reconnecting with Last-Event-ID: ${lastEventId}`)\n } else {\n console.log(`Establishing new SSE stream for session ${sessionId}`)\n }\n\n const transport = transports[sessionId]\n await transport.handleRequest(req, res)\n })\n\n let httpServer: Server | undefined\n return {\n context,\n start: async (actions) => {\n mountedActions = actions\n\n httpServer = app.listen(port, host, (error) => {\n if (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n console.log(`MCP Streamable HTTP Server listening on http://${host}:${port}/mcp`)\n })\n },\n stop: async () => {\n if (httpServer) {\n await new Promise<void>((resolve, reject) => {\n return httpServer!.close((err) => {\n if (err) {\n reject(err)\n } else {\n resolve()\n }\n })\n })\n }\n httpServer = undefined\n }\n }\n }\n}\n","import { AdapterFactory, toolResponse } from '@mcphero/core'\nimport { createLogger } from '@mcphero/logger'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { capitalCase, pascalCase } from 'change-case'\n\nexport const stdio: AdapterFactory = () => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'stdio' })\n const server = new McpServer({\n name: options.name,\n description: options.description,\n version: options.version\n }, {\n capabilities: { tools: {}, logging: {} }\n })\n return {\n context,\n start: async (actions) => {\n for (const action of actions) {\n server.registerTool(pascalCase(action.name), {\n title: capitalCase(action.name),\n description: action.description,\n inputSchema: action.input\n }, async (input, extra) => {\n const logger = createLogger({\n stream: false,\n onLog: (level, data) => {\n extra.sendNotification({ method: 'notifications/message', params: { level, data } })\n },\n onProgress: ({ progress, total, message }) => {\n if (!extra._meta?.progressToken) { return }\n extra.sendNotification({\n method: 'notifications/progress',\n params: {\n progress,\n total,\n message,\n progressToken: extra._meta.progressToken\n }\n })\n }\n })\n return action.run(input, context.fork({ logger, extra })).then((result) => {\n return toolResponse(result)\n }).catch((error) => {\n if (error instanceof Error) {\n return toolResponse({\n success: false,\n name: error.name,\n message: error.message,\n stack: error.stack\n })\n } else {\n return toolResponse({\n success: false,\n name: 'Unknown Error',\n message: 'An unknown error occured',\n error\n })\n }\n })\n })\n }\n const transport = new StdioServerTransport()\n await server.connect(transport)\n },\n stop: async () => {\n await server?.close()\n }\n }\n }\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAyB,mBAAiC,cAAc;AACxE,SAAS,uBAAuB;AAChC,SAAS,cAAc;AACvB,SAAS,qCAAqC;AAC9C,SAAS,kCAAkC,kCAAkC;AAC7E,SAAS,iBAAiB;AAC1B,SA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Aa;AAAA,kBAClB,SAAS;AAAA,kBACT,MAAM;AAAA,kBACN,SAAS;AAAA,kBACT;AAAA,gBACF,CAAC;AAAA,cACH;AAAA,YACF,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AACA,cAAM,YAAY,IAAI,qBAAqB;AAC3C,cAAM,OAAO,QAAQ,SAAS;AAAA,MAChC;AAAA,MACA,MAAM,YAAY;AAChB,cAAM,QAAQ,MAAM;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;","names":["randomUUID","toolResponse","createLogger","McpServer","capitalCase","pascalCase"]}
|
|
1
|
+
{"version":3,"sources":["../src/adapter/cliProxy.ts","../src/adapter/http.ts","../src/adapter/stdio.ts"],"sourcesContent":["import { intro } from '@clack/prompts'\nimport { AdapterFactory, parseToolResponse, ToolResponse, unwrap } from '@mcphero/core'\nimport { createCLILogger } from '@mcphero/logger'\nimport { Client } from '@modelcontextprotocol/sdk/client'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'\nimport { LoggingMessageNotificationSchema, ProgressNotificationSchema } from '@modelcontextprotocol/sdk/types'\nimport { kebabCase } from 'change-case'\nimport { Command } from 'commander'\nimport { randomUUID } from 'crypto'\nimport { z } from 'zod'\nimport { JSONSchema } from 'zod/v4/core'\n\nexport interface CliProxyOptions {\n url: URL\n}\n\nexport const cliProxy: AdapterFactory<CliProxyOptions> = ({ url }) => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'cliProxy' })\n const program = new Command()\n .name(options.name)\n .description(options.description)\n .version(options.version)\n .option('-s, --silent', 'Silent mode, prevent log messages', false)\n\n return {\n context,\n start: async () => {\n const client = new Client({\n name: options.name,\n description: options.description,\n version: options.version\n })\n const transport = new StreamableHTTPClientTransport(url)\n await client.connect(transport)\n const { tools } = await client.listTools()\n for (const tool of tools) {\n const name = kebabCase(tool.name)\n const command = program.command(name)\n if (tool.description) { command.description(tool.description) }\n const schema = z.fromJSONSchema(tool.inputSchema as JSONSchema.JSONSchema)\n if (!(schema instanceof z.ZodObject)) { throw new Error('Invalid schema') }\n const shape = schema.shape\n const keys = Object.keys(shape)\n for (const key of keys) {\n const [type, { defaultValue }] = unwrap(shape[key])\n const description = type.description\n if (type instanceof z.ZodBoolean) {\n command.option(`--${kebabCase(key)}`, description, defaultValue)\n command.option(`--no-${kebabCase(key)}`)\n } else if (type instanceof z.ZodNumber) {\n command.option(`--${kebabCase(key)} <number>`, description, defaultValue)\n } else if (type instanceof z.ZodString || type instanceof z.ZodEnum) {\n command.option(`--${kebabCase(key)} <string>`, description, defaultValue)\n } else if (type instanceof z.ZodObject || type instanceof z.ZodRecord || type instanceof z.ZodArray) {\n command.option(`--${kebabCase(key)} <json>`, description ?? '', JSON.parse, defaultValue)\n } else {\n throw new Error(`Invalid zod type: ${type.def.type}`)\n }\n }\n command.action(async (args) => {\n const { silent } = program.opts<{ silent: boolean }>()\n const logger = createCLILogger()\n if (!silent) {\n intro(`${options.name} - ${tool.name}`)\n client.setNotificationHandler(LoggingMessageNotificationSchema, ({ params: { level, data } }) => {\n logger[level](data)\n })\n client.setNotificationHandler(ProgressNotificationSchema, ({ params: { progress, total, message } }) => {\n logger.info({ progress, total, message })\n })\n }\n const input = await schema.parseAsync(args)\n const response = await client.callTool({\n name: tool.name,\n arguments: input,\n _meta: { progressToken: randomUUID() }\n })\n const result = parseToolResponse(response as ToolResponse)\n process.stdout.write(JSON.stringify(result, null, 2))\n })\n }\n await program.parseAsync()\n await transport.close()\n },\n stop: async () => { }\n }\n }\n}\n","import { AuthConfig, AuthInfo, generateProtectedResourceMetadata, OAuthRequest, OAuthResponse, validateToken } from '@mcphero/auth'\nimport { Action, AdapterFactory, SideloadResource, toolResponse } from '@mcphero/core'\nimport { createLogger } from '@mcphero/logger'\nimport { InMemoryEventStore } from '@modelcontextprotocol/sdk/examples/shared/inMemoryEventStore.js'\nimport { createMcpExpressApp, CreateMcpExpressAppOptions } from '@modelcontextprotocol/sdk/server/express.js'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'\nimport { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js'\nimport { capitalCase, pascalCase } from 'change-case'\nimport cors from 'cors'\nimport { randomUUID } from 'crypto'\nimport express, { Request, Response } from 'express'\nimport { readFile } from 'fs/promises'\nimport { Server } from 'http'\nimport { AsyncLocalStorage } from 'node:async_hooks'\n\nconst authStorage = new AsyncLocalStorage<AuthInfo>()\n\nexport interface HttpAdapterOptions extends CreateMcpExpressAppOptions {\n host: string\n port: number\n auth?: AuthConfig\n}\n\nexport const http: AdapterFactory<HttpAdapterOptions> = ({ host, port, auth, ...mcpOptions }) => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'http' })\n const app = createMcpExpressApp({ ...mcpOptions, host })\n app.use(cors({ exposedHeaders: ['WWW-Authenticate', 'Mcp-Session-Id', 'Last-Event-Id', 'Mcp-Protocol-Version'], origin: '*' }))\n\n if (auth?.authorizationServers?.length && auth.resourceUrl) {\n app.get('/.well-known/oauth-protected-resource', (_req: Request, res: Response) => {\n const metadata = generateProtectedResourceMetadata(auth.resourceUrl!, auth.authorizationServers!)\n res.json(metadata)\n })\n }\n\n const oauthPaths = new Set<string>()\n if (auth?.provider) {\n const provider = auth.provider\n const toOAuthReq = (req: Request): OAuthRequest => ({\n method: req.method,\n url: new URL(req.url, `${req.protocol}://${req.get('host')}`),\n headers: Object.fromEntries(Object.entries(req.headers).map(([k, v]) => [k, Array.isArray(v) ? v[0] : v])),\n body: req.body as Record<string, string> | undefined\n })\n const sendOAuth = (res: Response, oauthRes: OAuthResponse) => {\n for (const [key, value] of Object.entries(oauthRes.headers)) { res.header(key, value) }\n if (oauthRes.body) {\n res.status(oauthRes.status).send(typeof oauthRes.body === 'string' ? oauthRes.body : JSON.stringify(oauthRes.body))\n } else {\n res.status(oauthRes.status).end()\n }\n }\n\n oauthPaths.add('/.well-known/oauth-authorization-server')\n oauthPaths.add('/authorize')\n oauthPaths.add('/auth/callback')\n oauthPaths.add('/token')\n oauthPaths.add('/register')\n\n app.get('/.well-known/oauth-authorization-server', (_req: Request, res: Response) => {\n sendOAuth(res, provider.metadata())\n })\n app.get('/authorize', async (req: Request, res: Response) => {\n sendOAuth(res, await provider.authorize(toOAuthReq(req)))\n })\n app.get('/auth/callback', async (req: Request, res: Response) => {\n sendOAuth(res, await provider.callback(toOAuthReq(req)))\n })\n app.post('/token', express.urlencoded({ extended: false }), async (req: Request, res: Response) => {\n sendOAuth(res, await provider.token(toOAuthReq(req)))\n })\n app.post('/register', express.json(), async (req: Request, res: Response) => {\n sendOAuth(res, await provider.register(toOAuthReq(req)))\n })\n }\n\n if (auth) {\n app.use(async (req: Request, res: Response, next: (err?: unknown) => void) => {\n if (req.path.startsWith('/.well-known/') || oauthPaths.has(req.path)) { return next() }\n const result = await validateToken(req.headers.authorization, auth)\n if (result.error) {\n for (const [key, value] of Object.entries(result.error.headers)) {\n res.header(key, value)\n }\n res.status(result.error.statusCode).json(result.error.body)\n return\n }\n if (result.auth) {\n authStorage.run(result.auth, () => { next() })\n } else {\n next()\n }\n })\n }\n\n const transports: Record<string, StreamableHTTPServerTransport> = {}\n let mountedActions: Action[] = []\n\n const createServer = () => {\n const server = new McpServer({\n name: options.name,\n description: options.description,\n version: options.version\n }, {\n capabilities: { tools: {}, logging: {} }\n })\n for (const action of mountedActions) {\n server.registerTool(pascalCase(action.name), {\n title: capitalCase(action.name),\n description: action.description,\n inputSchema: action.input\n }, async (input, extra) => {\n const logger = createLogger({\n stream: process.stderr,\n onLog: (level, data) => {\n extra.sendNotification({ method: 'notifications/message', params: { level, data } })\n },\n onProgress: ({ progress, total, message }) => {\n if (!extra._meta?.progressToken) { return }\n extra.sendNotification({\n method: 'notifications/progress',\n params: {\n progress,\n total,\n message,\n progressToken: extra._meta.progressToken\n }\n })\n }\n })\n const currentAuth = authStorage.getStore()\n return action.run(input, context.fork({ logger, extra, ...(currentAuth ? { auth: currentAuth } : {}) })).then((result) => {\n return toolResponse(result)\n }).catch((error) => {\n if (error instanceof Error) {\n return toolResponse({ success: false, name: error.name, message: error.message, stack: error.stack })\n } else {\n return toolResponse({ success: false, name: 'Unknown Error', message: 'An unknown error occured', error })\n }\n })\n })\n }\n return server\n }\n\n app.get('/resource/:id', async (req: Request, res: Response) => {\n const id = req.params.id\n if (!id || typeof id !== 'string') { throw new Error('Invalid ID') }\n const resourceMeta: SideloadResource = JSON.parse(await readFile(`resources/${id}.json`, 'utf-8'))\n const buffer = await readFile(`resources/${id}`)\n res.status(200)\n res.header('Content-Type', resourceMeta.contentType)\n res.send(buffer)\n })\n\n app.post('/mcp', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n try {\n let transport: StreamableHTTPServerTransport\n if (sessionId && transports[sessionId]) {\n transport = transports[sessionId]\n } else if (isInitializeRequest(req.body)) {\n const eventStore = new InMemoryEventStore()\n transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n enableJsonResponse: false,\n eventStore,\n onsessioninitialized: (sId) => {\n console.log(`Session initialized with ID: ${sId}`)\n transports[sId] = transport\n }\n })\n transport.onerror = (error) => {\n console.error(error)\n }\n transport.onclose = () => {\n const sid = transport.sessionId\n if (sid && transports[sid]) {\n console.log(`Transport closed for session ${sid}, removing from transports map`)\n delete transports[sid]\n }\n }\n await createServer().connect(transport)\n await transport.handleRequest(req, res, req.body)\n return\n } else {\n res.status(404).json({\n jsonrpc: '2.0',\n error: { code: -32_000, message: 'Session not found' },\n id: null\n })\n return\n }\n\n // Handle the request with existing transport - no need to reconnect\n // The existing transport is already connected to the server\n await transport.handleRequest(req, res, req.body)\n } catch (error) {\n console.error('Error handling MCP request:', error)\n if (!res.headersSent) {\n res.status(500).json({\n jsonrpc: '2.0',\n error: { code: -32_603, message: 'Internal server error' },\n id: null\n })\n }\n }\n })\n\n app.get('/mcp', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send('Invalid or missing session ID')\n return\n }\n\n // Check for Last-Event-ID header for resumability\n const lastEventId = req.headers['last-event-id'] as string | undefined\n if (lastEventId) {\n console.log(`Client reconnecting with Last-Event-ID: ${lastEventId}`)\n } else {\n console.log(`Establishing new SSE stream for session ${sessionId}`)\n }\n\n const transport = transports[sessionId]\n await transport.handleRequest(req, res)\n })\n\n app.delete('/mcp', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send('Invalid or missing session ID')\n return\n }\n\n console.log(`Received session termination request for session ${sessionId}`)\n\n try {\n const transport = transports[sessionId]\n await transport.handleRequest(req, res)\n } catch (error) {\n console.error('Error handling session termination:', error)\n if (!res.headersSent) {\n res.status(500).send('Error processing session termination')\n }\n }\n })\n\n app.get('/mcp/resource/:id', async (req: Request, res: Response) => {\n const sessionId = req.headers['mcp-session-id'] as string | undefined\n if (!sessionId || !transports[sessionId]) {\n res.status(400).send('Invalid or missing session ID')\n return\n }\n\n // Check for Last-Event-ID header for resumability\n const lastEventId = req.headers['last-event-id'] as string | undefined\n if (lastEventId) {\n console.log(`Client reconnecting with Last-Event-ID: ${lastEventId}`)\n } else {\n console.log(`Establishing new SSE stream for session ${sessionId}`)\n }\n\n const transport = transports[sessionId]\n await transport.handleRequest(req, res)\n })\n\n let httpServer: Server | undefined\n return {\n context,\n start: async (actions) => {\n mountedActions = actions\n\n httpServer = app.listen(port, host, (error) => {\n if (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n console.log(`MCP Streamable HTTP Server listening on http://${host}:${port}/mcp`)\n })\n },\n stop: async () => {\n if (httpServer) {\n await new Promise<void>((resolve, reject) => {\n return httpServer!.close((err) => {\n if (err) {\n reject(err)\n } else {\n resolve()\n }\n })\n })\n }\n httpServer = undefined\n }\n }\n }\n}\n","import { AdapterFactory, toolResponse } from '@mcphero/core'\nimport { createLogger } from '@mcphero/logger'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { capitalCase, pascalCase } from 'change-case'\n\nexport const stdio: AdapterFactory = () => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'stdio' })\n const server = new McpServer({\n name: options.name,\n description: options.description,\n version: options.version\n }, {\n capabilities: { tools: {}, logging: {} }\n })\n return {\n context,\n start: async (actions) => {\n for (const action of actions) {\n server.registerTool(pascalCase(action.name), {\n title: capitalCase(action.name),\n description: action.description,\n inputSchema: action.input\n }, async (input, extra) => {\n const logger = createLogger({\n stream: false,\n onLog: (level, data) => {\n extra.sendNotification({ method: 'notifications/message', params: { level, data } })\n },\n onProgress: ({ progress, total, message }) => {\n if (!extra._meta?.progressToken) { return }\n extra.sendNotification({\n method: 'notifications/progress',\n params: {\n progress,\n total,\n message,\n progressToken: extra._meta.progressToken\n }\n })\n }\n })\n return action.run(input, context.fork({ logger, extra })).then((result) => {\n return toolResponse(result)\n }).catch((error) => {\n if (error instanceof Error) {\n return toolResponse({\n success: false,\n name: error.name,\n message: error.message,\n stack: error.stack\n })\n } else {\n return toolResponse({\n success: false,\n name: 'Unknown Error',\n message: 'An unknown error occured',\n error\n })\n }\n })\n })\n }\n const transport = new StdioServerTransport()\n await server.connect(transport)\n },\n stop: async () => {\n await server?.close()\n }\n }\n }\n}\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAyB,mBAAiC,cAAc;AACxE,SAAS,uBAAuB;AAChC,SAAS,cAAc;AACvB,SAAS,qCAAqC;AAC9C,SAAS,kCAAkC,kCAAkC;AAC7E,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAOX,IAAM,WAA4C,CAAC,EAAE,IAAI,MAAM;AACpE,SAAO,CAAC,SAAS,gBAAgB;AAC/B,UAAM,UAAU,YAAY,KAAK,EAAE,SAA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;AAAA,kBACN,SAAS;AAAA,kBACT;AAAA,gBACF,CAAC;AAAA,cACH;AAAA,YACF,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AACA,cAAM,YAAY,IAAI,qBAAqB;AAC3C,cAAM,OAAO,QAAQ,SAAS;AAAA,MAChC;AAAA,MACA,MAAM,YAAY;AAChB,cAAM,QAAQ,MAAM;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;","names":["randomUUID","toolResponse","createLogger","McpServer","capitalCase","pascalCase"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcphero/mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "MCP Hero MCP Package",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"cors": "^2.8.6",
|
|
19
19
|
"express": "^5.2.1",
|
|
20
20
|
"zod": "^4.3.6",
|
|
21
|
-
"@mcphero/
|
|
22
|
-
"@mcphero/
|
|
21
|
+
"@mcphero/auth": "1.2.0",
|
|
22
|
+
"@mcphero/core": "1.2.0",
|
|
23
|
+
"@mcphero/logger": "1.2.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@eslint/js": "^10.0.1",
|