@jrmc/adonis-mcp 1.0.0-alpha.13 → 1.0.0-alpha.15
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 +223 -21
- package/build/commands/commands.json +1 -1
- package/build/commands/inspector.d.ts +16 -0
- package/build/commands/inspector.d.ts.map +1 -0
- package/build/commands/inspector.js +54 -0
- package/build/src/response.d.ts +2 -2
- package/build/src/response.d.ts.map +1 -1
- package/build/src/response.js +4 -4
- package/build/src/server/contents/audio.d.ts +3 -2
- package/build/src/server/contents/audio.d.ts.map +1 -1
- package/build/src/server/contents/audio.js +16 -9
- package/build/src/server/contents/blob.d.ts +2 -1
- package/build/src/server/contents/blob.d.ts.map +1 -1
- package/build/src/server/contents/blob.js +13 -2
- package/build/src/server/contents/embedded_resource.d.ts +2 -1
- package/build/src/server/contents/embedded_resource.d.ts.map +1 -1
- package/build/src/server/contents/embedded_resource.js +21 -10
- package/build/src/server/contents/error.d.ts +1 -1
- package/build/src/server/contents/error.d.ts.map +1 -1
- package/build/src/server/contents/image.d.ts +3 -2
- package/build/src/server/contents/image.d.ts.map +1 -1
- package/build/src/server/contents/image.js +16 -9
- package/build/src/server/contents/resource_link.d.ts +4 -2
- package/build/src/server/contents/resource_link.d.ts.map +1 -1
- package/build/src/server/contents/resource_link.js +20 -9
- package/build/src/server/contents/structured.d.ts +1 -1
- package/build/src/server/contents/structured.d.ts.map +1 -1
- package/build/src/server/contents/text.d.ts +2 -1
- package/build/src/server/contents/text.d.ts.map +1 -1
- package/build/src/server/contents/text.js +18 -7
- package/build/src/server/context.d.ts +5 -1
- package/build/src/server/context.d.ts.map +1 -1
- package/build/src/server/context.js +26 -0
- package/build/src/server/{content.d.ts → contracts/content.d.ts} +4 -4
- package/build/src/server/contracts/content.d.ts.map +1 -0
- package/build/src/server/contracts/context.d.ts +29 -0
- package/build/src/server/contracts/context.d.ts.map +1 -0
- package/build/src/{types → server/contracts}/transport.d.ts +1 -1
- package/build/src/server/contracts/transport.d.ts.map +1 -0
- package/build/src/server/contracts/transport.js +7 -0
- package/build/src/server/methods/call_tool.d.ts +1 -1
- package/build/src/server/methods/call_tool.d.ts.map +1 -1
- package/build/src/server/methods/get_prompt.d.ts +1 -1
- package/build/src/server/methods/get_prompt.d.ts.map +1 -1
- package/build/src/server/methods/initialize.d.ts +1 -1
- package/build/src/server/methods/initialize.d.ts.map +1 -1
- package/build/src/server/methods/list_prompts.d.ts +1 -1
- package/build/src/server/methods/list_prompts.d.ts.map +1 -1
- package/build/src/server/methods/list_prompts.js +1 -16
- package/build/src/server/methods/list_resource_templates.d.ts +12 -0
- package/build/src/server/methods/list_resource_templates.d.ts.map +1 -0
- package/build/src/server/methods/list_resource_templates.js +31 -0
- package/build/src/server/methods/list_resources.d.ts +1 -1
- package/build/src/server/methods/list_resources.d.ts.map +1 -1
- package/build/src/server/methods/list_resources.js +2 -9
- package/build/src/server/methods/list_tools.d.ts +1 -1
- package/build/src/server/methods/list_tools.d.ts.map +1 -1
- package/build/src/server/methods/list_tools.js +1 -16
- package/build/src/server/methods/ping.d.ts +1 -1
- package/build/src/server/methods/ping.d.ts.map +1 -1
- package/build/src/server/methods/read_resource.d.ts +1 -1
- package/build/src/server/methods/read_resource.d.ts.map +1 -1
- package/build/src/server/methods/read_resource.js +7 -7
- package/build/src/server/prompt.d.ts +13 -9
- package/build/src/server/prompt.d.ts.map +1 -1
- package/build/src/server/prompt.js +17 -0
- package/build/src/server/resource.d.ts +9 -8
- package/build/src/server/resource.d.ts.map +1 -1
- package/build/src/server/resource.js +23 -0
- package/build/src/server/tool.d.ts +13 -9
- package/build/src/server/tool.d.ts.map +1 -1
- package/build/src/server/tool.js +17 -0
- package/build/src/server/transports/fake_transport.d.ts +2 -2
- package/build/src/server/transports/fake_transport.d.ts.map +1 -1
- package/build/src/server/transports/http_transport.d.ts +2 -2
- package/build/src/server/transports/http_transport.d.ts.map +1 -1
- package/build/src/server/transports/stdio_transport.d.ts +1 -1
- package/build/src/server/transports/stdio_transport.d.ts.map +1 -1
- package/build/src/server.d.ts +2 -1
- package/build/src/server.d.ts.map +1 -1
- package/build/src/server.js +1 -0
- package/build/src/types/content.d.ts +14 -10
- package/build/src/types/content.d.ts.map +1 -1
- package/build/src/types/context.d.ts +9 -22
- package/build/src/types/context.d.ts.map +1 -1
- package/build/src/types/method.d.ts +1 -1
- package/build/src/types/method.d.ts.map +1 -1
- package/build/src/utils/find_resource_pattern.d.ts +13 -0
- package/build/src/utils/find_resource_pattern.d.ts.map +1 -0
- package/build/src/utils/find_resource_pattern.js +29 -0
- package/build/src/utils/uri_template.d.ts +25 -0
- package/build/src/utils/uri_template.d.ts.map +1 -0
- package/build/src/utils/uri_template.js +240 -0
- package/build/stubs/make/mcp/prompts/main.ts.stub +3 -4
- package/build/stubs/make/mcp/resources/main.ts.stub +1 -1
- package/build/stubs/make/mcp/tools/main.ts.stub +3 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/build/src/server/content.d.ts.map +0 -1
- package/build/src/types/transport.d.ts.map +0 -1
- /package/build/src/server/{content.js → contracts/content.js} +0 -0
- /package/build/src/{types/transport.js → server/contracts/context.js} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { ErrorCode } from '../../enums/error.js';
|
|
8
|
+
import JsonRpcException from '../exceptions/jsonrpc_exception.js';
|
|
9
|
+
import { CursorPaginator } from '../pagination/cursor_paginator.js';
|
|
10
|
+
import Response from '../../response.js';
|
|
11
|
+
export default class ListResourceTemplates {
|
|
12
|
+
async handle(ctx) {
|
|
13
|
+
let nextCursor;
|
|
14
|
+
const paginator = new CursorPaginator(Object.values(await ctx.getResourceTemplates()), ctx.getPerPage(), ctx.request.params?.cursor);
|
|
15
|
+
const paginatedResources = paginator.paginate('resourceTemplates');
|
|
16
|
+
const resourceTemplates = await Promise.all(paginatedResources['resourceTemplates'].map(async (filepath) => {
|
|
17
|
+
try {
|
|
18
|
+
const { default: Resource } = await import(filepath);
|
|
19
|
+
const resource = new Resource();
|
|
20
|
+
return resource.toJson();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new JsonRpcException(`Error listing resource`, ErrorCode.InternalError, ctx.request.id, { error });
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
if (paginatedResources.nextCursor) {
|
|
27
|
+
nextCursor = paginatedResources.nextCursor;
|
|
28
|
+
}
|
|
29
|
+
return Response.toJsonRpc({ id: ctx.request.id, result: { resourceTemplates, nextCursor } });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import type { McpContext } from '../contracts/context.js';
|
|
7
8
|
import type { Method } from '../../types/method.js';
|
|
8
|
-
import type { McpContext } from '../../types/context.js';
|
|
9
9
|
export default class ListResources implements Method {
|
|
10
10
|
handle(ctx: McpContext): Promise<import("../../types/jsonrpc.js").JsonRpcResponse>;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_resources.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/list_resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"list_resources.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/list_resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAOnD,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,MAAM;IAC5C,MAAM,CAAC,GAAG,EAAE,UAAU;CAiC7B"}
|
|
@@ -11,20 +11,13 @@ import Response from '../../response.js';
|
|
|
11
11
|
export default class ListResources {
|
|
12
12
|
async handle(ctx) {
|
|
13
13
|
let nextCursor;
|
|
14
|
-
const paginator = new CursorPaginator(Object.values(ctx.
|
|
14
|
+
const paginator = new CursorPaginator(Object.values(await ctx.getResources()), ctx.getPerPage(), ctx.request.params?.cursor);
|
|
15
15
|
const paginatedResources = paginator.paginate('resources');
|
|
16
16
|
const resources = await Promise.all(paginatedResources['resources'].map(async (filepath) => {
|
|
17
17
|
try {
|
|
18
18
|
const { default: Resource } = await import(filepath);
|
|
19
19
|
const resource = new Resource();
|
|
20
|
-
return
|
|
21
|
-
name: resource.name,
|
|
22
|
-
uri: resource.uri,
|
|
23
|
-
title: resource.title,
|
|
24
|
-
description: resource.description,
|
|
25
|
-
size: resource.size,
|
|
26
|
-
mimeType: resource.mimeType,
|
|
27
|
-
};
|
|
20
|
+
return resource.toJson();
|
|
28
21
|
}
|
|
29
22
|
catch (error) {
|
|
30
23
|
throw new JsonRpcException(`Error listing resource`, ErrorCode.InternalError, ctx.request.id, { error });
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import type { McpContext } from '../contracts/context.js';
|
|
7
8
|
import type { Method } from '../../types/method.js';
|
|
8
|
-
import type { McpContext } from '../../types/context.js';
|
|
9
9
|
export default class ListTools implements Method {
|
|
10
10
|
handle(ctx: McpContext): Promise<import("../../types/jsonrpc.js").JsonRpcResponse>;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_tools.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/list_tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"list_tools.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/list_tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAOnD,MAAM,CAAC,OAAO,OAAO,SAAU,YAAW,MAAM;IACxC,MAAM,CAAC,GAAG,EAAE,UAAU;CAiC7B"}
|
|
@@ -17,22 +17,7 @@ export default class ListTools {
|
|
|
17
17
|
try {
|
|
18
18
|
const { default: Tool } = await import(filepath);
|
|
19
19
|
const tool = new Tool();
|
|
20
|
-
|
|
21
|
-
? tool.schema()
|
|
22
|
-
: {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {},
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
name: tool.name,
|
|
28
|
-
title: tool.title,
|
|
29
|
-
description: tool.description,
|
|
30
|
-
inputSchema: {
|
|
31
|
-
type: schema.type,
|
|
32
|
-
properties: schema.properties,
|
|
33
|
-
required: schema.required ?? [],
|
|
34
|
-
},
|
|
35
|
-
};
|
|
20
|
+
return tool.toJson();
|
|
36
21
|
}
|
|
37
22
|
catch (error) {
|
|
38
23
|
throw new JsonRpcException(`Error listing tool`, ErrorCode.InternalError, ctx.request.id, { error });
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import type { McpContext } from '../contracts/context.js';
|
|
7
8
|
import type { Method } from '../../types/method.js';
|
|
8
|
-
import type { McpContext } from '../../types/context.js';
|
|
9
9
|
export default class Ping implements Method {
|
|
10
10
|
handle(ctx: McpContext): import("../../types/jsonrpc.js").JsonRpcResponse;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/ping.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/ping.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAInD,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,MAAM;IACzC,MAAM,CAAC,GAAG,EAAE,UAAU;CAGvB"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import type { McpContext } from '../contracts/context.js';
|
|
7
8
|
import type { Method } from '../../types/method.js';
|
|
8
|
-
import type { McpContext } from '../../types/context.js';
|
|
9
9
|
export default class ReadResource implements Method {
|
|
10
10
|
handle(ctx: McpContext): Promise<import("../../types/jsonrpc.js").JsonRpcResponse>;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read_resource.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/read_resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"read_resource.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/read_resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AASnD,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,MAAM;IAC3C,MAAM,CAAC,GAAG,EAAE,UAAU;CA6B7B"}
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
import { ErrorCode } from '../../enums/error.js';
|
|
8
8
|
import JsonRpcException from '../exceptions/jsonrpc_exception.js';
|
|
9
9
|
import Response from '../../response.js';
|
|
10
|
+
import { findResource } from '../../utils/find_resource_pattern.js';
|
|
10
11
|
export default class ReadResource {
|
|
11
12
|
async handle(ctx) {
|
|
12
13
|
const resourceContext = ctx;
|
|
13
14
|
const params = ctx.request.params;
|
|
14
|
-
if (!params?.uri) {
|
|
15
|
+
if (!params?.uri || typeof params.uri !== 'string') {
|
|
15
16
|
throw new JsonRpcException(`The resource URI is required.`, ErrorCode.InvalidParams, resourceContext.request.id);
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const resource = new Resource(resourceContext);
|
|
18
|
+
const resource = await findResource({
|
|
19
|
+
uri: params.uri,
|
|
20
|
+
resourceList: resourceContext.resources,
|
|
21
|
+
ctx: resourceContext
|
|
22
|
+
});
|
|
23
23
|
const content = await resource.handle(resourceContext);
|
|
24
24
|
const data = [content];
|
|
25
25
|
const result = { contents: [] };
|
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { JSONSchema } from '../types/method.js';
|
|
8
8
|
import type { PromptContext } from '../types/context.js';
|
|
9
|
-
import type { Content } from '
|
|
10
|
-
export declare abstract class Prompt<T extends JSONSchema> {
|
|
9
|
+
import type { Content } from './contracts/content.js';
|
|
10
|
+
export declare abstract class Prompt<T extends JSONSchema = JSONSchema> {
|
|
11
11
|
abstract name: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
schema(): T;
|
|
15
|
+
toJson(): {
|
|
16
|
+
name: string;
|
|
17
|
+
title: string | undefined;
|
|
18
|
+
description: string | undefined;
|
|
19
|
+
inputSchema: T;
|
|
20
|
+
};
|
|
21
|
+
abstract handle(ctx?: PromptContext<T>): Promise<Content | Content[]>;
|
|
18
22
|
}
|
|
19
23
|
export type AnyPrompt = Prompt<JSONSchema>;
|
|
20
24
|
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/server/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/server/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD,8BAAsB,MAAM,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,MAAM,IAAI,CAAC;IAOX,MAAM;;;;;;IAWN,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,OAAO,EAAE,CAAC;CACtE;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -5,4 +5,21 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
export class Prompt {
|
|
8
|
+
title;
|
|
9
|
+
description;
|
|
10
|
+
schema() {
|
|
11
|
+
return {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
toJson() {
|
|
17
|
+
const schema = this.schema();
|
|
18
|
+
return {
|
|
19
|
+
name: this.name,
|
|
20
|
+
title: this.title,
|
|
21
|
+
description: this.description,
|
|
22
|
+
inputSchema: schema,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
8
25
|
}
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import type { ResourceContext } from '../types/context.js';
|
|
8
|
-
import type { Content } from '
|
|
9
|
-
export declare abstract class Resource {
|
|
10
|
-
|
|
11
|
-
abstract title?: string;
|
|
12
|
-
abstract description?: string;
|
|
8
|
+
import type { Content } from './contracts/content.js';
|
|
9
|
+
export declare abstract class Resource<T = {}> {
|
|
10
|
+
uri: string;
|
|
13
11
|
abstract name: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
toJson(): Record<string, unknown>;
|
|
17
|
+
abstract handle(ctx?: ResourceContext<T>): Promise<Content>;
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/server/resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/server/resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAKrD,8BAAsB,QAAQ,CAAC,CAAC,GAAG,EAAE;IACnC,GAAG,EAAE,MAAM,CAA+D;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM;IAkBN,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAC5D"}
|
|
@@ -4,5 +4,28 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import string from '@adonisjs/core/helpers/string';
|
|
8
|
+
import { UriTemplate } from '../utils/uri_template.js';
|
|
7
9
|
export class Resource {
|
|
10
|
+
uri = `file://resources/${string.dashCase(this.constructor.name)}`;
|
|
11
|
+
title;
|
|
12
|
+
description;
|
|
13
|
+
mimeType;
|
|
14
|
+
size;
|
|
15
|
+
toJson() {
|
|
16
|
+
const data = {
|
|
17
|
+
name: this.name,
|
|
18
|
+
title: this.title,
|
|
19
|
+
description: this.description,
|
|
20
|
+
size: this.size,
|
|
21
|
+
mimeType: this.mimeType,
|
|
22
|
+
};
|
|
23
|
+
if (UriTemplate.isTemplate(this.uri)) {
|
|
24
|
+
data.uriTemplate = this.uri;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
data.uri = this.uri;
|
|
28
|
+
}
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
8
31
|
}
|
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { JSONSchema } from '../types/method.js';
|
|
8
8
|
import type { ToolContext } from '../types/context.js';
|
|
9
|
-
import type { Content } from '
|
|
10
|
-
export declare abstract class Tool<T extends JSONSchema> {
|
|
9
|
+
import type { Content } from './contracts/content.js';
|
|
10
|
+
export declare abstract class Tool<T extends JSONSchema = JSONSchema> {
|
|
11
11
|
abstract name: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
schema(): T;
|
|
15
|
+
toJson(): {
|
|
16
|
+
name: string;
|
|
17
|
+
title: string | undefined;
|
|
18
|
+
description: string | undefined;
|
|
19
|
+
inputSchema: T;
|
|
20
|
+
};
|
|
21
|
+
abstract handle(ctx?: ToolContext<T>): Promise<Content | Content[]>;
|
|
18
22
|
}
|
|
19
23
|
export type AnyTool = Tool<JSONSchema>;
|
|
20
24
|
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/server/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/server/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD,8BAAsB,IAAI,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,MAAM,IAAI,CAAC;IAOX,MAAM;;;;;;IAWN,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,OAAO,EAAE,CAAC;CACpE;AAED,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,CAAA"}
|
package/build/src/server/tool.js
CHANGED
|
@@ -5,4 +5,21 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
export class Tool {
|
|
8
|
+
title;
|
|
9
|
+
description;
|
|
10
|
+
schema() {
|
|
11
|
+
return {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
toJson() {
|
|
17
|
+
const schema = this.schema();
|
|
18
|
+
return {
|
|
19
|
+
name: this.name,
|
|
20
|
+
title: this.title,
|
|
21
|
+
description: this.description,
|
|
22
|
+
inputSchema: schema,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
8
25
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { McpContext } from '
|
|
8
|
-
import type { Transport } from '
|
|
7
|
+
import type { McpContext } from '../contracts/context.js';
|
|
8
|
+
import type { Transport } from '../contracts/transport.js';
|
|
9
9
|
import type { JsonRpcResponse } from '../../types/jsonrpc.js';
|
|
10
10
|
export default class FakeTransport implements Transport {
|
|
11
11
|
sentMessages: JsonRpcResponse[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake_transport.d.ts","sourceRoot":"","sources":["../../../../src/server/transports/fake_transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fake_transport.d.ts","sourceRoot":"","sources":["../../../../src/server/transports/fake_transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,SAAS;IACrD,YAAY,EAAE,eAAe,EAAE,CAAK;IACpC,oBAAoB,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC,EAAE,CAAK;IACxD,iBAAiB,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC,EAAE,CAAK;IAErD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIpC,WAAW,CAAC,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAInC,QAAQ,CAAC,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAIhC,KAAK,IAAI,IAAI;IAMb,cAAc,IAAI,eAAe,GAAG,SAAS;CAG9C"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
8
|
-
import type { McpContext } from '
|
|
9
|
-
import type { Transport } from '
|
|
8
|
+
import type { McpContext } from '../contracts/context.js';
|
|
9
|
+
import type { Transport } from '../contracts/transport.js';
|
|
10
10
|
import type { JsonRpcResponse } from '../../types/jsonrpc.js';
|
|
11
11
|
export default class HttpTransport implements Transport {
|
|
12
12
|
#private;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_transport.d.ts","sourceRoot":"","sources":["../../../../src/server/transports/http_transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"http_transport.d.ts","sourceRoot":"","sources":["../../../../src/server/transports/http_transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,SAAS;;gBAEzC,GAAG,EAAE,WAAW;IAI5B,WAAW,CAAC,UAAU,EAAE,UAAU;IAMlC,QAAQ,CAAC,UAAU,EAAE,UAAU;IAM/B,IAAI,CAAC,OAAO,EAAE,eAAe;CAG9B"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { Transport } from '
|
|
7
|
+
import type { Transport } from '../contracts/transport.js';
|
|
8
8
|
import type { JsonRpcResponse } from '../../types/jsonrpc.js';
|
|
9
9
|
import { EventEmitter } from 'node:events';
|
|
10
10
|
export default class StdioTransport extends EventEmitter implements Transport {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio_transport.d.ts","sourceRoot":"","sources":["../../../../src/server/transports/stdio_transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"stdio_transport.d.ts","sourceRoot":"","sources":["../../../../src/server/transports/stdio_transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAI7D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAa,YAAW,SAAS;;IAK3E,MAAM,GAAI,OAAO,MAAM,UAGtB;;IAOK,iBAAiB;IAavB,IAAI,CAAC,OAAO,EAAE,eAAe;CAG9B"}
|
package/build/src/server.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { McpConfig } from './types/config.js';
|
|
8
8
|
import type { JsonRpcRequest } from './types/jsonrpc.js';
|
|
9
9
|
import type { ToolList, ResourceList, PromptList } from './types/method.js';
|
|
10
|
-
import type { Transport } from './
|
|
10
|
+
import type { Transport } from './server/contracts/transport.js';
|
|
11
11
|
import ServerContext from './server/context.js';
|
|
12
12
|
export default class Server {
|
|
13
13
|
#private;
|
|
@@ -28,6 +28,7 @@ export default class Server {
|
|
|
28
28
|
'tools/call': () => Promise<typeof import("./server/methods/call_tool.js")>;
|
|
29
29
|
'resources/list': () => Promise<typeof import("./server/methods/list_resources.js")>;
|
|
30
30
|
'resources/read': () => Promise<typeof import("./server/methods/read_resource.js")>;
|
|
31
|
+
'resources/templates/list': () => Promise<typeof import("./server/methods/list_resource_templates.js")>;
|
|
31
32
|
'prompts/list': () => Promise<typeof import("./server/methods/list_prompts.js")>;
|
|
32
33
|
'prompts/get': () => Promise<typeof import("./server/methods/get_prompt.js")>;
|
|
33
34
|
ping: () => Promise<typeof import("./server/methods/ping.js")>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAIhE,OAAO,aAAa,MAAM,qBAAqB,CAAA;AAG/C,MAAM,CAAC,OAAO,OAAO,MAAM;;IAEzB,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,MAAM,CAAwB;IACpC,OAAO,EAAE,MAAM,CAAU;IACzB,YAAY,EAAE,MAAM,CAA2E;IAE/F,wBAAwB,EAAE,MAAM,EAAE,CAA+B;IAEjE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAUhC;IAED,KAAK,EAAE,QAAQ,CAAK;IACpB,SAAS,EAAE,YAAY,CAAK;IAC5B,OAAO,EAAE,UAAU,CAAK;IAExB,mBAAmB,EAAE,MAAM,CAAK;IAChC,uBAAuB,EAAE,MAAM,CAAK;IAEpC,OAAO;;;;;;;;;;MAUN;gBAEW,MAAM,EAAE,SAAS;IAwB7B,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc;IAUhD,OAAO,CAAC,IAAI,EAAE,QAAQ;IAGtB,WAAW,CAAC,IAAI,EAAE,YAAY;IAG9B,SAAS,CAAC,IAAI,EAAE,UAAU;IAIpB,OAAO,CAAC,SAAS,EAAE,SAAS;IAI5B,MAAM,CAAC,WAAW,EAAE,cAAc;IA2CxC,aAAa,CAAC,cAAc,EAAE,cAAc;IAgB5C,iBAAiB;CAGlB"}
|
package/build/src/server.js
CHANGED
|
@@ -37,6 +37,7 @@ export default class Server {
|
|
|
37
37
|
'tools/call': () => import('./server/methods/call_tool.js'),
|
|
38
38
|
'resources/list': () => import('./server/methods/list_resources.js'),
|
|
39
39
|
'resources/read': () => import('./server/methods/read_resource.js'),
|
|
40
|
+
'resources/templates/list': () => import('./server/methods/list_resource_templates.js'),
|
|
40
41
|
'prompts/list': () => import('./server/methods/list_prompts.js'),
|
|
41
42
|
'prompts/get': () => import('./server/methods/get_prompt.js'),
|
|
42
43
|
'ping': () => import('./server/methods/ping.js'),
|
|
@@ -4,28 +4,32 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { Content } from '../server/content.js';
|
|
8
|
-
|
|
7
|
+
import type { Content } from '../server/contracts/content.js';
|
|
8
|
+
type HasMeta = {
|
|
9
|
+
withMeta: (meta: Record<string, unknown>) => Content;
|
|
10
|
+
};
|
|
11
|
+
export type TextPrompt = Content & HasMeta & {
|
|
9
12
|
asAssistant: () => Content;
|
|
10
13
|
asUser: () => Content;
|
|
11
14
|
};
|
|
12
|
-
export type ImagePrompt = Content & {
|
|
15
|
+
export type ImagePrompt = Content & HasMeta & {
|
|
13
16
|
asAssistant: () => Content;
|
|
14
17
|
asUser: () => Content;
|
|
15
18
|
};
|
|
16
|
-
export type AudioPrompt = Content & {
|
|
19
|
+
export type AudioPrompt = Content & HasMeta & {
|
|
17
20
|
asAssistant: () => Content;
|
|
18
21
|
asUser: () => Content;
|
|
19
22
|
};
|
|
20
|
-
export type EmbeddedResource = Content & {
|
|
23
|
+
export type EmbeddedResource = Content & HasMeta & {
|
|
21
24
|
asAssistant: () => Content;
|
|
22
25
|
asUser: () => Content;
|
|
23
26
|
};
|
|
24
|
-
export type Text = Content;
|
|
25
|
-
export type Blob = Content;
|
|
26
|
-
export type Image = Content;
|
|
27
|
-
export type Audio = Content;
|
|
28
|
-
export type ResourceLink = Content;
|
|
27
|
+
export type Text = Content & HasMeta;
|
|
28
|
+
export type Blob = Content & HasMeta;
|
|
29
|
+
export type Image = Content & HasMeta;
|
|
30
|
+
export type Audio = Content & HasMeta;
|
|
31
|
+
export type ResourceLink = Content & HasMeta;
|
|
29
32
|
export type Structured = Content;
|
|
30
33
|
export type Error = Content;
|
|
34
|
+
export {};
|
|
31
35
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/types/content.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/types/content.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAE7D,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG;IAC3C,WAAW,EAAE,MAAM,OAAO,CAAA;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG;IAC5C,WAAW,EAAE,MAAM,OAAO,CAAA;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG;IAC5C,WAAW,EAAE,MAAM,OAAO,CAAA;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG;IACjD,WAAW,EAAE,MAAM,OAAO,CAAA;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAA;AACpC,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAA;AACpC,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,CAAA;AACrC,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,CAAA;AACrC,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,CAAA;AAC5C,MAAM,MAAM,UAAU,GAAG,OAAO,CAAA;AAChC,MAAM,MAAM,KAAK,GAAG,OAAO,CAAA"}
|
|
@@ -4,39 +4,26 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { ToolList, ResourceList, PromptList } from './method.js';
|
|
8
|
-
import type { McpRequest, McpRequestType } from './request.js';
|
|
9
7
|
import type { McpResourceResponse, McpToolResponse, McpPromptResponse } from './response.js';
|
|
10
8
|
import type { JsonRpcRequest } from './jsonrpc.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
serverCapabilities: Record<string, any>;
|
|
15
|
-
serverName: string;
|
|
16
|
-
serverVersion: string;
|
|
17
|
-
instructions: string;
|
|
18
|
-
maxPaginationLength: number;
|
|
19
|
-
defaultPaginationLength: number;
|
|
20
|
-
tools: ToolList;
|
|
21
|
-
resources: ResourceList;
|
|
22
|
-
prompts: PromptList;
|
|
23
|
-
request: McpRequest;
|
|
24
|
-
response: this['requestType'] extends 'resource' ? McpResourceResponse : this['requestType'] extends 'prompt' ? McpPromptResponse : McpToolResponse;
|
|
25
|
-
getPerPage(requestedPerPage?: number): number;
|
|
26
|
-
}
|
|
27
|
-
export type ToolContext = Omit<McpContext, 'response' | 'requestType'> & {
|
|
9
|
+
import type { McpContext } from '../server/contracts/context.js';
|
|
10
|
+
import type { InferJSONSchema, JSONSchema } from './method.js';
|
|
11
|
+
export type ToolContext<T extends JSONSchema = JSONSchema> = Omit<McpContext, 'response' | 'requestType'> & {
|
|
28
12
|
requestType: 'tool';
|
|
29
13
|
response: McpToolResponse;
|
|
14
|
+
args?: InferJSONSchema<T>;
|
|
30
15
|
};
|
|
31
|
-
export type ResourceContext = Omit<McpContext, 'response' | 'requestType'> & {
|
|
16
|
+
export type ResourceContext<T = {}> = Omit<McpContext, 'response' | 'requestType'> & {
|
|
32
17
|
requestType: 'resource';
|
|
33
18
|
response: McpResourceResponse;
|
|
19
|
+
args?: T;
|
|
34
20
|
};
|
|
35
|
-
export type PromptContext = Omit<McpContext, 'response' | 'requestType'> & {
|
|
21
|
+
export type PromptContext<T extends JSONSchema = JSONSchema> = Omit<McpContext, 'response' | 'requestType'> & {
|
|
36
22
|
requestType: 'prompt';
|
|
37
23
|
response: McpPromptResponse;
|
|
24
|
+
args?: InferJSONSchema<T>;
|
|
38
25
|
};
|
|
39
|
-
export type ServerContextOptions = Omit<McpContext, 'requestType' | 'response' | 'request' | 'getPerPage'> & {
|
|
26
|
+
export type ServerContextOptions = Omit<McpContext, 'requestType' | 'response' | 'request' | 'getPerPage' | 'getResources' | 'getResourceTemplates'> & {
|
|
40
27
|
jsonRpcRequest: JsonRpcRequest;
|
|
41
28
|
};
|
|
42
29
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/types/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/types/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAC5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE9D,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,IAAI,CAC/D,UAAU,EACV,UAAU,GAAG,aAAa,CAC3B,GAAG;IACF,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,eAAe,CAAA;IACzB,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa,CAAC,GAAG;IACnF,WAAW,EAAE,UAAU,CAAA;IACvB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,IAAI,CAAC,EAAE,CAAC,CAAA;CACT,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,IAAI,CACjE,UAAU,EACV,UAAU,GAAG,aAAa,CAC3B,GAAG;IACF,WAAW,EAAE,QAAQ,CAAA;IACrB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,UAAU,EACV,aAAa,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,cAAc,GAAG,sBAAsB,CAChG,GAAG;IACF,cAAc,EAAE,cAAc,CAAA;CAC/B,CAAA"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { McpContext } from '
|
|
7
|
+
import type { McpContext } from '../server/contracts/context.js';
|
|
8
8
|
export interface Method {
|
|
9
9
|
handle(ctx: McpContext): Record<string, any>;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../src/types/method.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../src/types/method.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAEhE,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC7C;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC7C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AACjD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE/C,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAEnF,KAAK,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAA;AAE3D,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,QAAQ,GAC1E,MAAM,GACN,CAAC,CAAC,MAAM,CAAC,SAAS,QAAQ,GACxB,MAAM,GACN,CAAC,CAAC,MAAM,CAAC,SAAS,SAAS,GACzB,OAAO,GACP,CAAC,SAAS,YAAY,GACpB;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,CACtE,CAAC,CAAC,UAAU,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CACxE,GACG,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GACnC,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;CACpD,GACD,KAAK,CAAA;AAEf,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI;IAC3D,IAAI,EAAE,QAAQ,CAAA;IACd,UAAU,EAAE,CAAC,CAAA;IACb,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;CACvB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ResourceContext } from '../types/context.js';
|
|
2
|
+
import type { ResourceList } from '../types/method.js';
|
|
3
|
+
export declare function findResourcePattern({ uri, resourceList, ctx }: {
|
|
4
|
+
uri: string;
|
|
5
|
+
resourceList: ResourceList;
|
|
6
|
+
ctx?: ResourceContext;
|
|
7
|
+
}): string | undefined;
|
|
8
|
+
export declare function findResource({ uri, resourceList, ctx }: {
|
|
9
|
+
uri: string;
|
|
10
|
+
resourceList: ResourceList;
|
|
11
|
+
ctx: ResourceContext;
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
//# sourceMappingURL=find_resource_pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_resource_pattern.d.ts","sourceRoot":"","sources":["../../../src/utils/find_resource_pattern.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMtD,wBAAgB,mBAAmB,CAAC,EAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAC,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,YAAY,CAAC;IAAC,GAAG,CAAC,EAAE,eAAe,CAAA;CAAC,sBAe7H;AAGD,wBAAsB,YAAY,CAAC,EAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAC,EAAE;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,eAAe,CAAA;CAAC,gBAiB3H"}
|