@rudderjs/mcp 0.0.1
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 +21 -0
- package/README.md +152 -0
- package/dist/Mcp.d.ts +17 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +15 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/McpPrompt.d.ts +16 -0
- package/dist/McpPrompt.d.ts.map +1 -0
- package/dist/McpPrompt.js +13 -0
- package/dist/McpPrompt.js.map +1 -0
- package/dist/McpResource.d.ts +11 -0
- package/dist/McpResource.d.ts.map +1 -0
- package/dist/McpResource.js +12 -0
- package/dist/McpResource.js.map +1 -0
- package/dist/McpResponse.d.ts +7 -0
- package/dist/McpResponse.d.ts.map +1 -0
- package/dist/McpResponse.js +12 -0
- package/dist/McpResponse.js.map +1 -0
- package/dist/McpServer.d.ts +19 -0
- package/dist/McpServer.d.ts.map +1 -0
- package/dist/McpServer.js +19 -0
- package/dist/McpServer.js.map +1 -0
- package/dist/McpTool.d.ts +23 -0
- package/dist/McpTool.d.ts.map +1 -0
- package/dist/McpTool.js +13 -0
- package/dist/McpTool.js.map +1 -0
- package/dist/decorators.d.ts +12 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +30 -0
- package/dist/decorators.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +4 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +51 -0
- package/dist/provider.js.map +1 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +86 -0
- package/dist/runtime.js.map +1 -0
- package/dist/testing.d.ts +31 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +70 -0
- package/dist/testing.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +7 -0
- package/dist/utils.js.map +1 -0
- package/dist/zod-to-json-schema.d.ts +7 -0
- package/dist/zod-to-json-schema.d.ts.map +1 -0
- package/dist/zod-to-json-schema.js +53 -0
- package/dist/zod-to-json-schema.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Suleiman Shahbari
|
|
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,152 @@
|
|
|
1
|
+
# @rudderjs/mcp
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server framework for RudderJS. Build custom MCP servers that expose your application's functionality to AI agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @rudderjs/mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Add to your providers:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// bootstrap/providers.ts
|
|
17
|
+
import { mcp } from '@rudderjs/mcp'
|
|
18
|
+
|
|
19
|
+
export default [..., mcp()]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Defining a Server
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// app/Mcp/Servers/WeatherServer.ts
|
|
26
|
+
import { McpServer, Name, Version, Instructions } from '@rudderjs/mcp'
|
|
27
|
+
|
|
28
|
+
@Name('Weather Server')
|
|
29
|
+
@Version('1.0.0')
|
|
30
|
+
@Instructions('Provide weather information and forecasts.')
|
|
31
|
+
export class WeatherServer extends McpServer {
|
|
32
|
+
protected tools = [CurrentWeatherTool]
|
|
33
|
+
protected resources = [WeatherGuidelinesResource]
|
|
34
|
+
protected prompts = [DescribeWeatherPrompt]
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Tools
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// app/Mcp/Tools/CurrentWeatherTool.ts
|
|
42
|
+
import { McpTool, McpResponse, Description } from '@rudderjs/mcp'
|
|
43
|
+
import { z } from 'zod'
|
|
44
|
+
|
|
45
|
+
@Description('Get current weather for a location.')
|
|
46
|
+
export class CurrentWeatherTool extends McpTool {
|
|
47
|
+
schema() {
|
|
48
|
+
return z.object({
|
|
49
|
+
location: z.string().describe('City name'),
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async handle(input: Record<string, unknown>) {
|
|
54
|
+
const location = input.location as string
|
|
55
|
+
return McpResponse.text(`Weather in ${location}: sunny, 22C`)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Resources
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { McpResource, Description } from '@rudderjs/mcp'
|
|
64
|
+
|
|
65
|
+
@Description('Weather usage guidelines')
|
|
66
|
+
export class WeatherGuidelinesResource extends McpResource {
|
|
67
|
+
uri() { return 'weather://guidelines' }
|
|
68
|
+
async handle() { return 'Always check conditions before...' }
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Prompts
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { McpPrompt, Description } from '@rudderjs/mcp'
|
|
76
|
+
import type { McpPromptMessage } from '@rudderjs/mcp'
|
|
77
|
+
import { z } from 'zod'
|
|
78
|
+
|
|
79
|
+
@Description('Describe weather poetically')
|
|
80
|
+
export class DescribeWeatherPrompt extends McpPrompt {
|
|
81
|
+
arguments() {
|
|
82
|
+
return z.object({ location: z.string() })
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async handle(args: Record<string, unknown>): Promise<McpPromptMessage[]> {
|
|
86
|
+
return [{ role: 'user', content: `Describe the weather in ${args.location} poetically.` }]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Registration
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// routes/ai.ts
|
|
95
|
+
import { Mcp } from '@rudderjs/mcp'
|
|
96
|
+
import { WeatherServer } from '../app/Mcp/Servers/WeatherServer.js'
|
|
97
|
+
|
|
98
|
+
// HTTP endpoint (Streamable HTTP transport)
|
|
99
|
+
Mcp.web('/mcp/weather', WeatherServer)
|
|
100
|
+
|
|
101
|
+
// Local CLI command (stdio transport)
|
|
102
|
+
Mcp.local('weather', WeatherServer)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## CLI Commands
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
rudder mcp:start weather # Start a local server via stdio
|
|
109
|
+
rudder mcp:list # List all registered MCP servers
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Scaffolding
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
rudder make:mcp-server Weather
|
|
116
|
+
rudder make:mcp-tool CurrentWeather
|
|
117
|
+
rudder make:mcp-resource WeatherGuidelines
|
|
118
|
+
rudder make:mcp-prompt DescribeWeather
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Testing
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { McpTestClient } from '@rudderjs/mcp'
|
|
125
|
+
import { WeatherServer } from '../app/Mcp/Servers/WeatherServer.js'
|
|
126
|
+
|
|
127
|
+
const client = new McpTestClient(WeatherServer)
|
|
128
|
+
|
|
129
|
+
// Call a tool
|
|
130
|
+
const result = await client.callTool('current-weather', { location: 'London' })
|
|
131
|
+
|
|
132
|
+
// Assertions
|
|
133
|
+
client.assertToolExists('current-weather')
|
|
134
|
+
client.assertToolCount(1)
|
|
135
|
+
client.assertResourceExists('weather://guidelines')
|
|
136
|
+
client.assertPromptExists('describe-weather')
|
|
137
|
+
|
|
138
|
+
// List
|
|
139
|
+
const tools = await client.listTools()
|
|
140
|
+
const resources = await client.listResources()
|
|
141
|
+
const prompts = await client.listPrompts()
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Response Helpers
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { McpResponse } from '@rudderjs/mcp'
|
|
148
|
+
|
|
149
|
+
McpResponse.text('Plain text output')
|
|
150
|
+
McpResponse.json({ key: 'value' })
|
|
151
|
+
McpResponse.error('Something went wrong')
|
|
152
|
+
```
|
package/dist/Mcp.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { McpServer } from './McpServer.js';
|
|
2
|
+
type ServerClass = new () => McpServer;
|
|
3
|
+
export declare class Mcp {
|
|
4
|
+
private static webServers;
|
|
5
|
+
private static localServers;
|
|
6
|
+
/** Register an MCP server on an HTTP endpoint (Streamable HTTP transport) */
|
|
7
|
+
static web(path: string, server: ServerClass, middleware?: unknown[]): void;
|
|
8
|
+
/** Register an MCP server as a local CLI command (stdio transport) */
|
|
9
|
+
static local(name: string, server: ServerClass): void;
|
|
10
|
+
static getWebServers(): Map<string, {
|
|
11
|
+
server: ServerClass;
|
|
12
|
+
middleware: unknown[];
|
|
13
|
+
}>;
|
|
14
|
+
static getLocalServers(): Map<string, ServerClass>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=Mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mcp.d.ts","sourceRoot":"","sources":["../src/Mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,KAAK,WAAW,GAAG,UAAU,SAAS,CAAA;AAEtC,qBAAa,GAAG;IACd,OAAO,CAAC,MAAM,CAAC,UAAU,CAAyE;IAClG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAsC;IAEjE,6EAA6E;IAC7E,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,GAAE,OAAO,EAAO,GAAG,IAAI;IAI/E,sEAAsE;IACtE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAIrD,MAAM,CAAC,aAAa;gBAb6B,WAAW;oBAAc,OAAO,EAAE;;IAcnF,MAAM,CAAC,eAAe;CACvB"}
|
package/dist/Mcp.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class Mcp {
|
|
2
|
+
static webServers = new Map();
|
|
3
|
+
static localServers = new Map();
|
|
4
|
+
/** Register an MCP server on an HTTP endpoint (Streamable HTTP transport) */
|
|
5
|
+
static web(path, server, middleware = []) {
|
|
6
|
+
this.webServers.set(path, { server, middleware });
|
|
7
|
+
}
|
|
8
|
+
/** Register an MCP server as a local CLI command (stdio transport) */
|
|
9
|
+
static local(name, server) {
|
|
10
|
+
this.localServers.set(name, server);
|
|
11
|
+
}
|
|
12
|
+
static getWebServers() { return this.webServers; }
|
|
13
|
+
static getLocalServers() { return this.localServers; }
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Mcp.js.map
|
package/dist/Mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mcp.js","sourceRoot":"","sources":["../src/Mcp.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,GAAG;IACN,MAAM,CAAC,UAAU,GAAgE,IAAI,GAAG,EAAE,CAAA;IAC1F,MAAM,CAAC,YAAY,GAA6B,IAAI,GAAG,EAAE,CAAA;IAEjE,6EAA6E;IAC7E,MAAM,CAAC,GAAG,CAAC,IAAY,EAAE,MAAmB,EAAE,aAAwB,EAAE;QACtE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IACnD,CAAC;IAED,sEAAsE;IACtE,MAAM,CAAC,KAAK,CAAC,IAAY,EAAE,MAAmB;QAC5C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,aAAa,KAAK,OAAO,IAAI,CAAC,UAAU,CAAA,CAAC,CAAC;IACjD,MAAM,CAAC,eAAe,KAAK,OAAO,IAAI,CAAC,YAAY,CAAA,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export interface McpPromptMessage {
|
|
3
|
+
role: 'user' | 'assistant';
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class McpPrompt {
|
|
7
|
+
/** Prompt name */
|
|
8
|
+
name(): string;
|
|
9
|
+
/** Description */
|
|
10
|
+
description(): string;
|
|
11
|
+
/** Arguments schema */
|
|
12
|
+
arguments?(): z.ZodObject<z.ZodRawShape>;
|
|
13
|
+
/** Generate prompt messages */
|
|
14
|
+
abstract handle(args: Record<string, unknown>): Promise<McpPromptMessage[]>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=McpPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpPrompt.d.ts","sourceRoot":"","sources":["../src/McpPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAI5B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,8BAAsB,SAAS;IAC7B,kBAAkB;IAClB,IAAI,IAAI,MAAM;IAId,kBAAkB;IAClB,WAAW,IAAI,MAAM;IAIrB,uBAAuB;IACvB,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAExC,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAC5E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { toKebabCase } from './utils.js';
|
|
2
|
+
import { getDescription } from './decorators.js';
|
|
3
|
+
export class McpPrompt {
|
|
4
|
+
/** Prompt name */
|
|
5
|
+
name() {
|
|
6
|
+
return toKebabCase(this.constructor.name.replace(/Prompt$/, ''));
|
|
7
|
+
}
|
|
8
|
+
/** Description */
|
|
9
|
+
description() {
|
|
10
|
+
return getDescription(this.constructor) ?? '';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=McpPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpPrompt.js","sourceRoot":"","sources":["../src/McpPrompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAOhD,MAAM,OAAgB,SAAS;IAC7B,kBAAkB;IAClB,IAAI;QACF,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAA;IAClE,CAAC;IAED,kBAAkB;IAClB,WAAW;QACT,OAAO,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;IAC/C,CAAC;CAOF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare abstract class McpResource {
|
|
2
|
+
/** Resource URI pattern */
|
|
3
|
+
abstract uri(): string;
|
|
4
|
+
/** MIME type */
|
|
5
|
+
mimeType(): string;
|
|
6
|
+
/** Resource description */
|
|
7
|
+
description(): string;
|
|
8
|
+
/** Handle resource read */
|
|
9
|
+
abstract handle(): Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=McpResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpResource.d.ts","sourceRoot":"","sources":["../src/McpResource.ts"],"names":[],"mappings":"AAEA,8BAAsB,WAAW;IAC/B,2BAA2B;IAC3B,QAAQ,CAAC,GAAG,IAAI,MAAM;IAEtB,gBAAgB;IAChB,QAAQ,IAAI,MAAM;IAIlB,2BAA2B;IAC3B,WAAW,IAAI,MAAM;IAIrB,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;CACnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getDescription } from './decorators.js';
|
|
2
|
+
export class McpResource {
|
|
3
|
+
/** MIME type */
|
|
4
|
+
mimeType() {
|
|
5
|
+
return 'text/plain';
|
|
6
|
+
}
|
|
7
|
+
/** Resource description */
|
|
8
|
+
description() {
|
|
9
|
+
return getDescription(this.constructor) ?? '';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=McpResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpResource.js","sourceRoot":"","sources":["../src/McpResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAgB,WAAW;IAI/B,gBAAgB;IAChB,QAAQ;QACN,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,2BAA2B;IAC3B,WAAW;QACT,OAAO,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;IAC/C,CAAC;CAIF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { McpToolResult } from './McpTool.js';
|
|
2
|
+
export declare class McpResponse {
|
|
3
|
+
static text(content: string): McpToolResult;
|
|
4
|
+
static json(data: unknown): McpToolResult;
|
|
5
|
+
static error(message: string): McpToolResult;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=McpResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpResponse.d.ts","sourceRoot":"","sources":["../src/McpResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,qBAAa,WAAW;IACtB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IAI3C,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa;IAIzC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;CAG7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class McpResponse {
|
|
2
|
+
static text(content) {
|
|
3
|
+
return { content: [{ type: 'text', text: content }] };
|
|
4
|
+
}
|
|
5
|
+
static json(data) {
|
|
6
|
+
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
7
|
+
}
|
|
8
|
+
static error(message) {
|
|
9
|
+
return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=McpResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpResponse.js","sourceRoot":"","sources":["../src/McpResponse.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAW;IACtB,MAAM,CAAC,IAAI,CAAC,OAAe;QACzB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAA;IACvD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAa;QACvB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IAC7E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe;QAC1B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAClF,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { McpTool } from './McpTool.js';
|
|
2
|
+
import type { McpResource } from './McpResource.js';
|
|
3
|
+
import type { McpPrompt } from './McpPrompt.js';
|
|
4
|
+
export interface McpServerMetadata {
|
|
5
|
+
name?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
instructions?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class McpServer {
|
|
10
|
+
/** Tool classes to register */
|
|
11
|
+
protected tools: (new () => McpTool)[];
|
|
12
|
+
/** Resource classes to register */
|
|
13
|
+
protected resources: (new () => McpResource)[];
|
|
14
|
+
/** Prompt classes to register */
|
|
15
|
+
protected prompts: (new () => McpPrompt)[];
|
|
16
|
+
/** Server metadata — override or use decorators */
|
|
17
|
+
metadata(): Required<Pick<McpServerMetadata, 'name' | 'version'>> & Pick<McpServerMetadata, 'instructions'>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=McpServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpServer.d.ts","sourceRoot":"","sources":["../src/McpServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,8BAAsB,SAAS;IAC7B,+BAA+B;IAC/B,SAAS,CAAC,KAAK,EAAE,CAAC,UAAU,OAAO,CAAC,EAAE,CAAK;IAE3C,mCAAmC;IACnC,SAAS,CAAC,SAAS,EAAE,CAAC,UAAU,WAAW,CAAC,EAAE,CAAK;IAEnD,iCAAiC;IACjC,SAAS,CAAC,OAAO,EAAE,CAAC,UAAU,SAAS,CAAC,EAAE,CAAK;IAE/C,mDAAmD;IACnD,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC;CAQ5G"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getServerMetadata } from './decorators.js';
|
|
2
|
+
export class McpServer {
|
|
3
|
+
/** Tool classes to register */
|
|
4
|
+
tools = [];
|
|
5
|
+
/** Resource classes to register */
|
|
6
|
+
resources = [];
|
|
7
|
+
/** Prompt classes to register */
|
|
8
|
+
prompts = [];
|
|
9
|
+
/** Server metadata — override or use decorators */
|
|
10
|
+
metadata() {
|
|
11
|
+
const meta = getServerMetadata(this.constructor);
|
|
12
|
+
return {
|
|
13
|
+
name: meta.name ?? this.constructor.name,
|
|
14
|
+
version: meta.version ?? '1.0.0',
|
|
15
|
+
...(meta.instructions != null ? { instructions: meta.instructions } : {}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=McpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpServer.js","sourceRoot":"","sources":["../src/McpServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQnD,MAAM,OAAgB,SAAS;IAC7B,+BAA+B;IACrB,KAAK,GAA0B,EAAE,CAAA;IAE3C,mCAAmC;IACzB,SAAS,GAA8B,EAAE,CAAA;IAEnD,iCAAiC;IACvB,OAAO,GAA4B,EAAE,CAAA;IAE/C,mDAAmD;IACnD,QAAQ;QACN,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAChD,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI;YACxC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,OAAO;YAChC,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1E,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export interface McpToolResult {
|
|
3
|
+
content: Array<{
|
|
4
|
+
type: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'image';
|
|
8
|
+
data: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
}>;
|
|
11
|
+
isError?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class McpTool {
|
|
14
|
+
/** Tool name — derived from class name if not overridden. ClassName -> kebab-case minus "Tool" suffix */
|
|
15
|
+
name(): string;
|
|
16
|
+
/** Tool description — override or use @Description decorator */
|
|
17
|
+
description(): string;
|
|
18
|
+
/** Input schema using Zod */
|
|
19
|
+
abstract schema(): z.ZodObject<z.ZodRawShape>;
|
|
20
|
+
/** Handle the tool call */
|
|
21
|
+
abstract handle(input: Record<string, unknown>): Promise<McpToolResult>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=McpTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpTool.d.ts","sourceRoot":"","sources":["../src/McpTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAI5B,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAClG,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,8BAAsB,OAAO;IAC3B,yGAAyG;IACzG,IAAI,IAAI,MAAM;IAId,gEAAgE;IAChE,WAAW,IAAI,MAAM;IAIrB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAE7C,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;CACxE"}
|
package/dist/McpTool.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { toKebabCase } from './utils.js';
|
|
2
|
+
import { getDescription } from './decorators.js';
|
|
3
|
+
export class McpTool {
|
|
4
|
+
/** Tool name — derived from class name if not overridden. ClassName -> kebab-case minus "Tool" suffix */
|
|
5
|
+
name() {
|
|
6
|
+
return toKebabCase(this.constructor.name.replace(/Tool$/, ''));
|
|
7
|
+
}
|
|
8
|
+
/** Tool description — override or use @Description decorator */
|
|
9
|
+
description() {
|
|
10
|
+
return getDescription(this.constructor) ?? '';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=McpTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpTool.js","sourceRoot":"","sources":["../src/McpTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAOhD,MAAM,OAAgB,OAAO;IAC3B,yGAAyG;IACzG,IAAI;QACF,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,gEAAgE;IAChE,WAAW;QACT,OAAO,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;IAC/C,CAAC;CAOF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export declare function Name(name: string): ClassDecorator;
|
|
3
|
+
export declare function Version(version: string): ClassDecorator;
|
|
4
|
+
export declare function Instructions(instructions: string): ClassDecorator;
|
|
5
|
+
export declare function Description(description: string): ClassDecorator;
|
|
6
|
+
export declare function getServerMetadata(target: Function): {
|
|
7
|
+
name: string | undefined;
|
|
8
|
+
version: string | undefined;
|
|
9
|
+
instructions: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare function getDescription(target: Function): string | undefined;
|
|
12
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAOzB,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAEjD;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAEvD;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAEjE;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAE/D;AAGD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAM/I;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAEnE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
const NAME_KEY = Symbol('mcp:name');
|
|
3
|
+
const VERSION_KEY = Symbol('mcp:version');
|
|
4
|
+
const INSTRUCTIONS_KEY = Symbol('mcp:instructions');
|
|
5
|
+
const DESCRIPTION_KEY = Symbol('mcp:description');
|
|
6
|
+
export function Name(name) {
|
|
7
|
+
return (target) => { Reflect.defineMetadata(NAME_KEY, name, target); };
|
|
8
|
+
}
|
|
9
|
+
export function Version(version) {
|
|
10
|
+
return (target) => { Reflect.defineMetadata(VERSION_KEY, version, target); };
|
|
11
|
+
}
|
|
12
|
+
export function Instructions(instructions) {
|
|
13
|
+
return (target) => { Reflect.defineMetadata(INSTRUCTIONS_KEY, instructions, target); };
|
|
14
|
+
}
|
|
15
|
+
export function Description(description) {
|
|
16
|
+
return (target) => { Reflect.defineMetadata(DESCRIPTION_KEY, description, target); };
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
19
|
+
export function getServerMetadata(target) {
|
|
20
|
+
return {
|
|
21
|
+
name: Reflect.getMetadata(NAME_KEY, target),
|
|
22
|
+
version: Reflect.getMetadata(VERSION_KEY, target),
|
|
23
|
+
instructions: Reflect.getMetadata(INSTRUCTIONS_KEY, target),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
27
|
+
export function getDescription(target) {
|
|
28
|
+
return Reflect.getMetadata(DESCRIPTION_KEY, target);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;AACnC,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AACzC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AACnD,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAEjD,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA,CAAC,CAAC,CAAA;AACvE,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA,CAAC,CAAC,CAAA;AAC7E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,YAAoB;IAC/C,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,gBAAgB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA,CAAC,CAAC,CAAA;AACvF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC7C,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA,CAAC,CAAC,CAAA;AACrF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAAC,MAAgB;IAChD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAuB;QACjE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,CAAuB;QACvE,YAAY,EAAE,OAAO,CAAC,WAAW,CAAC,gBAAgB,EAAE,MAAM,CAAuB;KAClF,CAAA;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAuB,CAAA;AAC3E,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { McpServer } from './McpServer.js';
|
|
2
|
+
export type { McpServerMetadata } from './McpServer.js';
|
|
3
|
+
export { McpTool } from './McpTool.js';
|
|
4
|
+
export type { McpToolResult } from './McpTool.js';
|
|
5
|
+
export { McpResource } from './McpResource.js';
|
|
6
|
+
export { McpPrompt } from './McpPrompt.js';
|
|
7
|
+
export type { McpPromptMessage } from './McpPrompt.js';
|
|
8
|
+
export { McpResponse } from './McpResponse.js';
|
|
9
|
+
export { Mcp } from './Mcp.js';
|
|
10
|
+
export { Name, Version, Instructions, Description } from './decorators.js';
|
|
11
|
+
export { createSdkServer, startStdio } from './runtime.js';
|
|
12
|
+
export { mcp } from './provider.js';
|
|
13
|
+
export { McpTestClient } from './testing.js';
|
|
14
|
+
//# 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,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { McpServer } from './McpServer.js';
|
|
2
|
+
export { McpTool } from './McpTool.js';
|
|
3
|
+
export { McpResource } from './McpResource.js';
|
|
4
|
+
export { McpPrompt } from './McpPrompt.js';
|
|
5
|
+
export { McpResponse } from './McpResponse.js';
|
|
6
|
+
export { Mcp } from './Mcp.js';
|
|
7
|
+
export { Name, Version, Instructions, Description } from './decorators.js';
|
|
8
|
+
export { createSdkServer, startStdio } from './runtime.js';
|
|
9
|
+
export { mcp } from './provider.js';
|
|
10
|
+
export { McpTestClient } from './testing.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,wBAAgB,GAAG,IAAI,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAoD/D"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ServiceProvider } from '@rudderjs/core';
|
|
2
|
+
import { Mcp } from './Mcp.js';
|
|
3
|
+
export function mcp() {
|
|
4
|
+
class McpServiceProvider extends ServiceProvider {
|
|
5
|
+
register() {
|
|
6
|
+
this.app.instance('mcp', Mcp);
|
|
7
|
+
}
|
|
8
|
+
async boot() {
|
|
9
|
+
try {
|
|
10
|
+
const { rudder } = await import('@rudderjs/core');
|
|
11
|
+
// mcp:start <name> — start a local server via stdio
|
|
12
|
+
rudder.command('mcp:start', async (args) => {
|
|
13
|
+
const name = args[0];
|
|
14
|
+
const ServerClass = name != null ? Mcp.getLocalServers().get(name) : undefined;
|
|
15
|
+
if (!ServerClass) {
|
|
16
|
+
console.error(`MCP server "${name}" not found. Available: ${[...Mcp.getLocalServers().keys()].join(', ')}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const { startStdio } = await import('./runtime.js');
|
|
20
|
+
await startStdio(new ServerClass());
|
|
21
|
+
}).description('Start an MCP server (stdio)');
|
|
22
|
+
// mcp:list — list all registered servers
|
|
23
|
+
rudder.command('mcp:list', () => {
|
|
24
|
+
const web = [...Mcp.getWebServers().entries()];
|
|
25
|
+
const local = [...Mcp.getLocalServers().entries()];
|
|
26
|
+
if (web.length === 0 && local.length === 0) {
|
|
27
|
+
console.log('No MCP servers registered.');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (web.length > 0) {
|
|
31
|
+
console.log('\nWeb Servers:');
|
|
32
|
+
for (const [path, { server }] of web) {
|
|
33
|
+
console.log(` ${path} -> ${server.name}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (local.length > 0) {
|
|
37
|
+
console.log('\nLocal Servers:');
|
|
38
|
+
for (const [serverName, server] of local) {
|
|
39
|
+
console.log(` ${serverName} -> ${server.name}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}).description('List registered MCP servers');
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// rudder not available
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return McpServiceProvider;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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
3
|
+
export declare function createSdkServer(server: McpServer): Server;
|
|
4
|
+
/** Start a server with stdio transport */
|
|
5
|
+
export declare function startStdio(server: McpServer): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAUlE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAU/C,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAgFzD;AAED,0CAA0C;AAC1C,wBAAsB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjE"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, ListResourcesRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { zodToJsonSchema } from './zod-to-json-schema.js';
|
|
5
|
+
function getProtected(server, key, fallback) {
|
|
6
|
+
return (server[key]) ?? fallback;
|
|
7
|
+
}
|
|
8
|
+
export function createSdkServer(server) {
|
|
9
|
+
const meta = server.metadata();
|
|
10
|
+
const sdk = new Server({ name: meta.name, version: meta.version }, { capabilities: { tools: {}, resources: {}, prompts: {} } });
|
|
11
|
+
const toolClasses = getProtected(server, 'tools', []);
|
|
12
|
+
const resourceClasses = getProtected(server, 'resources', []);
|
|
13
|
+
const promptClasses = getProtected(server, 'prompts', []);
|
|
14
|
+
const tools = toolClasses.map((T) => new T());
|
|
15
|
+
const resources = resourceClasses.map((R) => new R());
|
|
16
|
+
const prompts = promptClasses.map((P) => new P());
|
|
17
|
+
// ── Tools ────────────────────────────────────────────────
|
|
18
|
+
sdk.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
19
|
+
tools: tools.map((t) => ({
|
|
20
|
+
name: t.name(),
|
|
21
|
+
description: t.description(),
|
|
22
|
+
inputSchema: zodToJsonSchema(t.schema()),
|
|
23
|
+
})),
|
|
24
|
+
}));
|
|
25
|
+
sdk.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
26
|
+
const tool = tools.find((t) => t.name() === request.params.name);
|
|
27
|
+
if (!tool) {
|
|
28
|
+
return { content: [{ type: 'text', text: `Unknown tool: ${request.params.name}` }], isError: true };
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const result = await tool.handle((request.params.arguments ?? {}));
|
|
32
|
+
return { ...result };
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
36
|
+
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// ── Resources ────────────────────────────────────────────
|
|
40
|
+
sdk.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
41
|
+
resources: resources.map((r) => ({
|
|
42
|
+
uri: r.uri(),
|
|
43
|
+
name: r.uri(),
|
|
44
|
+
description: r.description(),
|
|
45
|
+
mimeType: r.mimeType(),
|
|
46
|
+
})),
|
|
47
|
+
}));
|
|
48
|
+
sdk.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
49
|
+
const resource = resources.find((r) => r.uri() === request.params.uri);
|
|
50
|
+
if (!resource) {
|
|
51
|
+
throw new Error(`Unknown resource: ${request.params.uri}`);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
contents: [{
|
|
55
|
+
uri: resource.uri(),
|
|
56
|
+
text: await resource.handle(),
|
|
57
|
+
mimeType: resource.mimeType(),
|
|
58
|
+
}],
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
// ── Prompts ──────────────────────────────────────────────
|
|
62
|
+
sdk.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
63
|
+
prompts: prompts.map((p) => ({
|
|
64
|
+
name: p.name(),
|
|
65
|
+
description: p.description(),
|
|
66
|
+
...(p.arguments ? { arguments: Object.keys(p.arguments().shape).map((k) => ({ name: k, required: true })) } : {}),
|
|
67
|
+
})),
|
|
68
|
+
}));
|
|
69
|
+
sdk.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
70
|
+
const prompt = prompts.find((p) => p.name() === request.params.name);
|
|
71
|
+
if (!prompt) {
|
|
72
|
+
throw new Error(`Unknown prompt: ${request.params.name}`);
|
|
73
|
+
}
|
|
74
|
+
return { messages: await prompt.handle((request.params.arguments ?? {})) };
|
|
75
|
+
});
|
|
76
|
+
return sdk;
|
|
77
|
+
}
|
|
78
|
+
/** Start a server with stdio transport */
|
|
79
|
+
export async function startStdio(server) {
|
|
80
|
+
const sdk = createSdkServer(server);
|
|
81
|
+
const transport = new StdioServerTransport();
|
|
82
|
+
await sdk.connect(transport);
|
|
83
|
+
}
|
|
84
|
+
// TODO: Add createHttpHandler once StreamableHTTPServerTransport / SSEServerTransport
|
|
85
|
+
// integration pattern is finalized. The low-level Server class requires manual transport wiring.
|
|
86
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oCAAoC,CAAA;AAK3C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAA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AI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,KAAgC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7I,CAAC,CAAC;KACJ,CAAC,CAAC,CAAA;IAEH,GAAG,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACpE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAC3D,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAA4B,CAAC,EAAE,CAAA;IACvG,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,0CAA0C;AAC1C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAiB;IAChD,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AAC9B,CAAC;AAED,sFAAsF;AACtF,iGAAiG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { McpServer } from './McpServer.js';
|
|
2
|
+
import type { McpToolResult } from './McpTool.js';
|
|
3
|
+
import type { McpPromptMessage } from './McpPrompt.js';
|
|
4
|
+
export declare class McpTestClient {
|
|
5
|
+
private tools;
|
|
6
|
+
private resources;
|
|
7
|
+
private prompts;
|
|
8
|
+
constructor(ServerClass: new () => McpServer);
|
|
9
|
+
callTool(name: string, input?: Record<string, unknown>): Promise<McpToolResult>;
|
|
10
|
+
listTools(): Promise<Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}>>;
|
|
14
|
+
listResources(): Promise<Array<{
|
|
15
|
+
uri: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}>>;
|
|
18
|
+
listPrompts(): Promise<Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}>>;
|
|
22
|
+
readResource(uri: string): Promise<string>;
|
|
23
|
+
getPrompt(name: string, args?: Record<string, unknown>): Promise<McpPromptMessage[]>;
|
|
24
|
+
assertToolExists(name: string): void;
|
|
25
|
+
assertToolCount(expected: number): void;
|
|
26
|
+
assertResourceExists(uri: string): void;
|
|
27
|
+
assertResourceCount(expected: number): void;
|
|
28
|
+
assertPromptExists(name: string): void;
|
|
29
|
+
assertPromptCount(expected: number): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAW,aAAa,EAAE,MAAM,cAAc,CAAA;AAE1D,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjE,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,OAAO,CAAa;gBAEhB,WAAW,EAAE,UAAU,SAAS;IAiBtC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAMnF,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAIlE,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAIrE,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAIpE,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM1C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAM9F,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMpC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMvC,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMvC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAM3C,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMtC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAK1C"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export class McpTestClient {
|
|
2
|
+
tools;
|
|
3
|
+
resources;
|
|
4
|
+
prompts;
|
|
5
|
+
constructor(ServerClass) {
|
|
6
|
+
const server = new ServerClass();
|
|
7
|
+
const record = server;
|
|
8
|
+
this.tools = (record['tools'] ?? []).map((T) => new T());
|
|
9
|
+
this.resources = (record['resources'] ?? []).map((R) => new R());
|
|
10
|
+
this.prompts = (record['prompts'] ?? []).map((P) => new P());
|
|
11
|
+
}
|
|
12
|
+
async callTool(name, input = {}) {
|
|
13
|
+
const tool = this.tools.find((t) => t.name() === name);
|
|
14
|
+
if (!tool)
|
|
15
|
+
throw new Error(`Tool "${name}" not found`);
|
|
16
|
+
return tool.handle(input);
|
|
17
|
+
}
|
|
18
|
+
async listTools() {
|
|
19
|
+
return this.tools.map((t) => ({ name: t.name(), description: t.description() }));
|
|
20
|
+
}
|
|
21
|
+
async listResources() {
|
|
22
|
+
return this.resources.map((r) => ({ uri: r.uri(), description: r.description() }));
|
|
23
|
+
}
|
|
24
|
+
async listPrompts() {
|
|
25
|
+
return this.prompts.map((p) => ({ name: p.name(), description: p.description() }));
|
|
26
|
+
}
|
|
27
|
+
async readResource(uri) {
|
|
28
|
+
const resource = this.resources.find((r) => r.uri() === uri);
|
|
29
|
+
if (!resource)
|
|
30
|
+
throw new Error(`Resource "${uri}" not found`);
|
|
31
|
+
return resource.handle();
|
|
32
|
+
}
|
|
33
|
+
async getPrompt(name, args = {}) {
|
|
34
|
+
const prompt = this.prompts.find((p) => p.name() === name);
|
|
35
|
+
if (!prompt)
|
|
36
|
+
throw new Error(`Prompt "${name}" not found`);
|
|
37
|
+
return prompt.handle(args);
|
|
38
|
+
}
|
|
39
|
+
assertToolExists(name) {
|
|
40
|
+
if (!this.tools.some((t) => t.name() === name)) {
|
|
41
|
+
throw new Error(`Expected tool "${name}" to exist, but it was not found`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
assertToolCount(expected) {
|
|
45
|
+
if (this.tools.length !== expected) {
|
|
46
|
+
throw new Error(`Expected ${expected} tools, but found ${this.tools.length}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
assertResourceExists(uri) {
|
|
50
|
+
if (!this.resources.some((r) => r.uri() === uri)) {
|
|
51
|
+
throw new Error(`Expected resource "${uri}" to exist, but it was not found`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
assertResourceCount(expected) {
|
|
55
|
+
if (this.resources.length !== expected) {
|
|
56
|
+
throw new Error(`Expected ${expected} resources, but found ${this.resources.length}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
assertPromptExists(name) {
|
|
60
|
+
if (!this.prompts.some((p) => p.name() === name)) {
|
|
61
|
+
throw new Error(`Expected prompt "${name}" to exist, but it was not found`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
assertPromptCount(expected) {
|
|
65
|
+
if (this.prompts.length !== expected) {
|
|
66
|
+
throw new Error(`Expected ${expected} prompts, but found ${this.prompts.length}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,aAAa;IAChB,KAAK,CAAW;IAChB,SAAS,CAAe;IACxB,OAAO,CAAa;IAE5B,YAAY,WAAgC;QAC1C,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;QAChC,MAAM,MAAM,GAAG,MAA4C,CAAA;QAE3D,IAAI,CAAC,KAAK,GAAG,CACV,MAAM,CAAC,OAAO,CAA0C,IAAI,EAAE,CAChE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAErB,IAAI,CAAC,SAAS,GAAG,CACd,MAAM,CAAC,WAAW,CAA8C,IAAI,EAAE,CACxE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAErB,IAAI,CAAC,OAAO,GAAG,CACZ,MAAM,CAAC,SAAS,CAA4C,IAAI,EAAE,CACpE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,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QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,yBAAyB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAA;QACvF,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,IAAY;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,kCAAkC,CAAC,CAAA;QAC7E,CAAC;IACH,CAAC;IAED,iBAAiB,CAAC,QAAgB;QAChC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,uBAAuB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;CACF"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,WAAW,EAAE,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal Zod-to-JSON-Schema converter for MCP tool input schemas.
|
|
4
|
+
* Handles the common primitive types used in tool parameters.
|
|
5
|
+
*/
|
|
6
|
+
export declare function zodToJsonSchema(schema: z.ZodObject<z.ZodRawShape>): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=zod-to-json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-to-json-schema.d.ts","sourceRoot":"","sources":["../src/zod-to-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoB3F"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Zod-to-JSON-Schema converter for MCP tool input schemas.
|
|
3
|
+
* Handles the common primitive types used in tool parameters.
|
|
4
|
+
*/
|
|
5
|
+
export function zodToJsonSchema(schema) {
|
|
6
|
+
const shape = schema.shape;
|
|
7
|
+
const properties = {};
|
|
8
|
+
const required = [];
|
|
9
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
10
|
+
const field = value;
|
|
11
|
+
properties[key] = zodTypeToJson(field);
|
|
12
|
+
// If the field is not optional, mark as required
|
|
13
|
+
if (!isOptional(field)) {
|
|
14
|
+
required.push(key);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties,
|
|
20
|
+
...(required.length > 0 ? { required } : {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function zodTypeToJson(field) {
|
|
24
|
+
const def = field._def;
|
|
25
|
+
const typeName = def['typeName'];
|
|
26
|
+
switch (typeName) {
|
|
27
|
+
case 'ZodString':
|
|
28
|
+
return { type: 'string', ...(def['description'] ? { description: def['description'] } : {}) };
|
|
29
|
+
case 'ZodNumber':
|
|
30
|
+
return { type: 'number', ...(def['description'] ? { description: def['description'] } : {}) };
|
|
31
|
+
case 'ZodBoolean':
|
|
32
|
+
return { type: 'boolean', ...(def['description'] ? { description: def['description'] } : {}) };
|
|
33
|
+
case 'ZodArray':
|
|
34
|
+
return { type: 'array', items: zodTypeToJson(def['type']), ...(def['description'] ? { description: def['description'] } : {}) };
|
|
35
|
+
case 'ZodOptional':
|
|
36
|
+
return zodTypeToJson(def['innerType']);
|
|
37
|
+
case 'ZodDefault':
|
|
38
|
+
return zodTypeToJson(def['innerType']);
|
|
39
|
+
case 'ZodEnum':
|
|
40
|
+
return { type: 'string', enum: def['values'], ...(def['description'] ? { description: def['description'] } : {}) };
|
|
41
|
+
default:
|
|
42
|
+
return { type: 'string' };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function isOptional(field) {
|
|
46
|
+
const typeName = field._def['typeName'];
|
|
47
|
+
if (typeName === 'ZodOptional')
|
|
48
|
+
return true;
|
|
49
|
+
if (typeName === 'ZodDefault')
|
|
50
|
+
return true;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=zod-to-json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-to-json-schema.js","sourceRoot":"","sources":["../src/zod-to-json-schema.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkC;IAChE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;IAC1B,MAAM,UAAU,GAA4B,EAAE,CAAA;IAC9C,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,KAAqB,CAAA;QACnC,UAAU,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;QAEtC,iDAAiD;QAC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AAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,aAAa,CAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;QAC3J,KAAK,aAAa;YAChB,OAAO,aAAa,CAAC,GAAG,CAAC,WAAW,CAAiB,CAAC,CAAA;QACxD,KAAK,YAAY;YACf,OAAO,aAAa,CAAC,GAAG,CAAC,WAAW,CAAiB,CAAC,CAAA;QACxD,KAAK,SAAS;YACZ,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAa,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,aAAa,CAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;QAC1I;YACE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAmB;IACrC,MAAM,QAAQ,GAAI,KAAK,CAAC,IAAgC,CAAC,UAAU,CAAuB,CAAA;IAC1F,IAAI,QAAQ,KAAK,aAAa;QAAE,OAAO,IAAI,CAAA;IAC3C,IAAI,QAAQ,KAAK,YAAY;QAAE,OAAO,IAAI,CAAA;IAC1C,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rudderjs/mcp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "MCP (Model Context Protocol) server framework for RudderJS",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/rudderjs/rudder",
|
|
9
|
+
"directory": "packages/mcp"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.13.0",
|
|
25
|
+
"reflect-metadata": "^0.2.0",
|
|
26
|
+
"zod": "^3.23.0",
|
|
27
|
+
"@rudderjs/core": "0.0.8"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"typescript": "^5.4.0"
|
|
32
|
+
},
|
|
33
|
+
"author": "Suleiman Shahbari",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.build.json",
|
|
36
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"test": "tsc -p tsconfig.test.json && node --test dist-test/*.test.js; EXIT=$?; rm -rf dist-test; exit $EXIT"
|
|
40
|
+
}
|
|
41
|
+
}
|