spiceflow 1.16.1 → 1.17.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/README.md +5 -1
- package/dist/mcp.d.ts +15 -3
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +14 -2
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
- package/src/mcp.ts +24 -7
package/README.md
CHANGED
|
@@ -1088,7 +1088,11 @@ const app = new Spiceflow()
|
|
|
1088
1088
|
})
|
|
1089
1089
|
|
|
1090
1090
|
// Add Spiceflow tools to your existing server
|
|
1091
|
-
const mcpServer = await addMcpTools({
|
|
1091
|
+
const mcpServer = await addMcpTools({
|
|
1092
|
+
mcpServer: existingServer,
|
|
1093
|
+
app,
|
|
1094
|
+
ignorePaths: ['/mcp', '/sse']
|
|
1095
|
+
})
|
|
1092
1096
|
|
|
1093
1097
|
// Now your existing server has access to all Spiceflow routes as tools
|
|
1094
1098
|
```
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { SSEServerTransportSpiceflow } from './mcp-transport.ts';
|
|
2
2
|
import { AnySpiceflow, Spiceflow } from './spiceflow.ts';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Add MCP tools to an existing MCP server from a Spiceflow app
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* await addMcpTools({
|
|
9
|
+
* mcpServer,
|
|
10
|
+
* app,
|
|
11
|
+
* ignorePaths: ['/sse', '/mcp']
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function addMcpTools<const App extends AnySpiceflow, Paths extends string = App extends Spiceflow<any, any, any, any, any, any, infer RoutePaths> ? RoutePaths : string>({ mcpServer, app, ignorePaths, onlyPaths, }: {
|
|
5
16
|
mcpServer: McpServer;
|
|
6
|
-
app:
|
|
7
|
-
|
|
17
|
+
app: App;
|
|
18
|
+
ignorePaths: Paths[];
|
|
19
|
+
onlyPaths?: Paths[];
|
|
8
20
|
}): Promise<McpServer>;
|
|
9
21
|
export declare const mcp: <Path extends string = "/mcp">({ path, name, version, transports, }?: {
|
|
10
22
|
path?: Path | undefined;
|
package/dist/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAGhE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAInE,wBAAsB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAGhE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAInE;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,KAAK,CAAC,GAAG,SAAS,YAAY,EAC9B,KAAK,SAAS,MAAM,GAAG,GAAG,SAAS,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC,GACxF,UAAU,GACV,MAAM,EACV,EACA,SAAS,EACT,GAAG,EACH,WAAW,EACX,SAAS,GACV,EAAE;IACD,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,GAAG,CAAA;IACR,WAAW,EAAE,KAAK,EAAE,CAAA;IACpB,SAAS,CAAC,EAAE,KAAK,EAAE,CAAA;CACpB,GAAG,OAAO,CAAC,SAAS,CAAC,CAyBrB;AAED,eAAO,MAAM,GAAG,GAAI,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE;;;;;CAQ5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6EL,CAAA"}
|
package/dist/mcp.js
CHANGED
|
@@ -3,7 +3,18 @@ import { createMCPServer } from "./openapi-to-mcp.js";
|
|
|
3
3
|
import { openapi } from "./openapi.js";
|
|
4
4
|
import { Spiceflow } from "./spiceflow.js";
|
|
5
5
|
const defaultTransports = new Map();
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Add MCP tools to an existing MCP server from a Spiceflow app
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* await addMcpTools({
|
|
11
|
+
* mcpServer,
|
|
12
|
+
* app,
|
|
13
|
+
* ignorePaths: ['/sse', '/mcp']
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export async function addMcpTools({ mcpServer, app, ignorePaths, onlyPaths, }) {
|
|
7
18
|
// Always add the OpenAPI route
|
|
8
19
|
app.use(openapi({ path: '/_mcp_openapi' }));
|
|
9
20
|
const basePath = app.topLevelApp?.basePath || '';
|
|
@@ -13,7 +24,8 @@ export async function addMcpTools({ mcpServer, app, path, }) {
|
|
|
13
24
|
.then((r) => r.json()));
|
|
14
25
|
const { server: configuredServer } = createMCPServer({
|
|
15
26
|
server: mcpServer,
|
|
16
|
-
ignorePaths: ['/_mcp_openapi',
|
|
27
|
+
ignorePaths: ['/_mcp_openapi', ...ignorePaths],
|
|
28
|
+
paths: onlyPaths,
|
|
17
29
|
fetch: (url, init) => {
|
|
18
30
|
const req = new Request(url, init);
|
|
19
31
|
return app.handle(req);
|
package/dist/mcp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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gBAClC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;YACD,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAE/B,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC5C,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBAChC,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;YAClD,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAC,QAAQ,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEJ,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
package/package.json
CHANGED
package/src/mcp.ts
CHANGED
|
@@ -7,16 +7,32 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
|
7
7
|
|
|
8
8
|
const defaultTransports = new Map<string, SSEServerTransportSpiceflow>()
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Add MCP tools to an existing MCP server from a Spiceflow app
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* await addMcpTools({
|
|
15
|
+
* mcpServer,
|
|
16
|
+
* app,
|
|
17
|
+
* ignorePaths: ['/sse', '/mcp']
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export async function addMcpTools<
|
|
22
|
+
const App extends AnySpiceflow,
|
|
23
|
+
Paths extends string = App extends Spiceflow<any, any, any, any, any, any, infer RoutePaths>
|
|
24
|
+
? RoutePaths
|
|
25
|
+
: string
|
|
26
|
+
>({
|
|
11
27
|
mcpServer,
|
|
12
28
|
app,
|
|
13
|
-
|
|
14
|
-
|
|
29
|
+
ignorePaths,
|
|
30
|
+
onlyPaths,
|
|
15
31
|
}: {
|
|
16
32
|
mcpServer: McpServer
|
|
17
|
-
app:
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
app: App
|
|
34
|
+
ignorePaths: Paths[]
|
|
35
|
+
onlyPaths?: Paths[]
|
|
20
36
|
}): Promise<McpServer> {
|
|
21
37
|
// Always add the OpenAPI route
|
|
22
38
|
app.use(openapi({ path: '/_mcp_openapi' }))
|
|
@@ -32,7 +48,8 @@ export async function addMcpTools({
|
|
|
32
48
|
|
|
33
49
|
const { server: configuredServer } = createMCPServer({
|
|
34
50
|
server: mcpServer,
|
|
35
|
-
ignorePaths: ['/_mcp_openapi',
|
|
51
|
+
ignorePaths: ['/_mcp_openapi', ...ignorePaths],
|
|
52
|
+
paths: onlyPaths,
|
|
36
53
|
fetch: (url, init) => {
|
|
37
54
|
const req = new Request(url, init)
|
|
38
55
|
return app.handle(req)
|