@jrmc/adonis-mcp 1.0.0-alpha.10
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 +292 -0
- package/build/commands/commands.json +1 -0
- package/build/commands/main.d.ts +4 -0
- package/build/commands/main.js +36 -0
- package/build/commands/make/tool.d.ts +16 -0
- package/build/commands/make/tool.d.ts.map +1 -0
- package/build/commands/make/tool.js +35 -0
- package/build/commands/start.d.ts +16 -0
- package/build/commands/start.d.ts.map +1 -0
- package/build/commands/start.js +30 -0
- package/build/configure.d.ts +9 -0
- package/build/configure.d.ts.map +1 -0
- package/build/configure.js +21 -0
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +4 -0
- package/build/providers/mcp_provider.d.ts +27 -0
- package/build/providers/mcp_provider.d.ts.map +1 -0
- package/build/providers/mcp_provider.js +48 -0
- package/build/src/define_config.d.ts +9 -0
- package/build/src/define_config.d.ts.map +1 -0
- package/build/src/define_config.js +12 -0
- package/build/src/enums/error.d.ts +16 -0
- package/build/src/enums/error.d.ts.map +1 -0
- package/build/src/enums/error.js +18 -0
- package/build/src/enums/role.d.ts +12 -0
- package/build/src/enums/role.d.ts.map +1 -0
- package/build/src/enums/role.js +12 -0
- package/build/src/request.d.ts +18 -0
- package/build/src/request.d.ts.map +1 -0
- package/build/src/request.js +12 -0
- package/build/src/response.d.ts +32 -0
- package/build/src/response.d.ts.map +1 -0
- package/build/src/response.js +33 -0
- package/build/src/server/context.d.ts +27 -0
- package/build/src/server/context.d.ts.map +1 -0
- package/build/src/server/context.js +33 -0
- package/build/src/server/controllers/mcp_controller.d.ts +11 -0
- package/build/src/server/controllers/mcp_controller.d.ts.map +1 -0
- package/build/src/server/controllers/mcp_controller.js +15 -0
- package/build/src/server/exceptions/jsonrpc_exception.d.ts +9 -0
- package/build/src/server/exceptions/jsonrpc_exception.d.ts.map +1 -0
- package/build/src/server/exceptions/jsonrpc_exception.js +22 -0
- package/build/src/server/methods/call_tool.d.ts +12 -0
- package/build/src/server/methods/call_tool.d.ts.map +1 -0
- package/build/src/server/methods/call_tool.js +40 -0
- package/build/src/server/methods/get_prompt.d.ts +12 -0
- package/build/src/server/methods/get_prompt.d.ts.map +1 -0
- package/build/src/server/methods/get_prompt.js +12 -0
- package/build/src/server/methods/initialize.d.ts +12 -0
- package/build/src/server/methods/initialize.d.ts.map +1 -0
- package/build/src/server/methods/initialize.js +31 -0
- package/build/src/server/methods/list_prompts.d.ts +12 -0
- package/build/src/server/methods/list_prompts.d.ts.map +1 -0
- package/build/src/server/methods/list_prompts.js +13 -0
- package/build/src/server/methods/list_resources.d.ts +12 -0
- package/build/src/server/methods/list_resources.d.ts.map +1 -0
- package/build/src/server/methods/list_resources.js +13 -0
- package/build/src/server/methods/list_tools.d.ts +12 -0
- package/build/src/server/methods/list_tools.d.ts.map +1 -0
- package/build/src/server/methods/list_tools.js +46 -0
- package/build/src/server/methods/ping.d.ts +12 -0
- package/build/src/server/methods/ping.d.ts.map +1 -0
- package/build/src/server/methods/ping.js +12 -0
- package/build/src/server/methods/read_resource.d.ts +12 -0
- package/build/src/server/methods/read_resource.d.ts.map +1 -0
- package/build/src/server/methods/read_resource.js +12 -0
- package/build/src/server/pagination/cursor_paginator.d.ts +12 -0
- package/build/src/server/pagination/cursor_paginator.d.ts.map +1 -0
- package/build/src/server/pagination/cursor_paginator.js +45 -0
- package/build/src/server/tool.d.ts +18 -0
- package/build/src/server/tool.d.ts.map +1 -0
- package/build/src/server/tool.js +8 -0
- package/build/src/server/transports/fake_transport.d.ts +20 -0
- package/build/src/server/transports/fake_transport.d.ts.map +1 -0
- package/build/src/server/transports/fake_transport.js +28 -0
- package/build/src/server/transports/http_transport.d.ts +18 -0
- package/build/src/server/transports/http_transport.d.ts.map +1 -0
- package/build/src/server/transports/http_transport.js +27 -0
- package/build/src/server/transports/stdio_transport.d.ts +17 -0
- package/build/src/server/transports/stdio_transport.d.ts.map +1 -0
- package/build/src/server/transports/stdio_transport.js +39 -0
- package/build/src/server.d.ts +45 -0
- package/build/src/server.d.ts.map +1 -0
- package/build/src/server.js +132 -0
- package/build/src/types/config.d.ts +15 -0
- package/build/src/types/config.d.ts.map +1 -0
- package/build/src/types/config.js +7 -0
- package/build/src/types/context.d.ts +28 -0
- package/build/src/types/context.d.ts.map +1 -0
- package/build/src/types/context.js +7 -0
- package/build/src/types/method.d.ts +37 -0
- package/build/src/types/method.d.ts.map +1 -0
- package/build/src/types/method.js +7 -0
- package/build/src/types/notification.d.ts +14 -0
- package/build/src/types/notification.d.ts.map +1 -0
- package/build/src/types/notification.js +7 -0
- package/build/src/types/request.d.ts +44 -0
- package/build/src/types/request.d.ts.map +1 -0
- package/build/src/types/request.js +7 -0
- package/build/src/types/response.d.ts +46 -0
- package/build/src/types/response.d.ts.map +1 -0
- package/build/src/types/response.js +7 -0
- package/build/src/types/transport.d.ts +14 -0
- package/build/src/types/transport.d.ts.map +1 -0
- package/build/src/types/transport.js +7 -0
- package/build/src/utils/stdio.d.ts +20 -0
- package/build/src/utils/stdio.d.ts.map +1 -0
- package/build/src/utils/stdio.js +36 -0
- package/build/stubs/config.ts.stub +10 -0
- package/build/stubs/main.d.ts +2 -0
- package/build/stubs/main.d.ts.map +1 -0
- package/build/stubs/main.js +2 -0
- package/build/stubs/make/mcp/prompts/main.ts.stub +27 -0
- package/build/stubs/make/mcp/resources/main.ts.stub +29 -0
- package/build/stubs/make/mcp/tools/main.ts.stub +41 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../../src/enums/role.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,aAAK,IAAI;IACP,IAAI,SAAS;IACb,SAAS,cAAc;CACxB;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { JsonRpcRequest } from './types/request.js';
|
|
8
|
+
export default class Request implements JsonRpcRequest {
|
|
9
|
+
jsonrpc: '2.0';
|
|
10
|
+
id: string | number;
|
|
11
|
+
method: string;
|
|
12
|
+
params?: {
|
|
13
|
+
cursor?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
constructor(request: JsonRpcRequest);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,CAAC,OAAO,OAAO,OAAQ,YAAW,cAAc;IACpD,OAAO,EAAE,KAAK,CAAA;IACd,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;gBAEW,OAAO,EAAE,cAAc;CAMpC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { JsonRpcResponse, McpResponse } from './types/response.js';
|
|
8
|
+
export default class Response implements McpResponse {
|
|
9
|
+
text(text: string): {
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
13
|
+
image(data: string, mimeType: string, _meta?: Record<string, unknown>): {
|
|
14
|
+
type: "image";
|
|
15
|
+
data: string;
|
|
16
|
+
mimeType: string;
|
|
17
|
+
_meta: Record<string, unknown> | undefined;
|
|
18
|
+
};
|
|
19
|
+
audio(data: string, mimeType: string, _meta?: Record<string, unknown>): {
|
|
20
|
+
type: "audio";
|
|
21
|
+
data: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
_meta: Record<string, unknown> | undefined;
|
|
24
|
+
};
|
|
25
|
+
error(message: string, code?: number, data?: Record<string, unknown>): {
|
|
26
|
+
message: string;
|
|
27
|
+
code: number;
|
|
28
|
+
data: Record<string, unknown> | undefined;
|
|
29
|
+
};
|
|
30
|
+
static toJsonRpc({ id, result, error }: Omit<JsonRpcResponse, 'jsonrpc'>): JsonRpcResponse;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEvE,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,WAAW;IAClD,IAAI,CAAC,IAAI,EAAE,MAAM;;;;IAIjB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;IAIrE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;IAIrE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;IAQpE,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG,eAAe;CAQ3F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
export default class Response {
|
|
9
|
+
text(text) {
|
|
10
|
+
return { type: 'text', text };
|
|
11
|
+
}
|
|
12
|
+
image(data, mimeType, _meta) {
|
|
13
|
+
return { type: 'image', data, mimeType, _meta };
|
|
14
|
+
}
|
|
15
|
+
audio(data, mimeType, _meta) {
|
|
16
|
+
return { type: 'audio', data, mimeType, _meta };
|
|
17
|
+
}
|
|
18
|
+
error(message, code, data) {
|
|
19
|
+
return {
|
|
20
|
+
message,
|
|
21
|
+
code: code ?? ErrorCode.InternalError,
|
|
22
|
+
data,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
static toJsonRpc({ id, result, error }) {
|
|
26
|
+
return {
|
|
27
|
+
jsonrpc: '2.0',
|
|
28
|
+
id,
|
|
29
|
+
result,
|
|
30
|
+
error,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { McpContext, ServerContextOptions } from '../types/context.js';
|
|
8
|
+
import type { ToolList, ResourceList, PromptList } from '../types/method.js';
|
|
9
|
+
import type { McpRequest } from '../types/request.js';
|
|
10
|
+
import McpResponse from '../response.js';
|
|
11
|
+
export default class ServerContext implements McpContext {
|
|
12
|
+
supportedProtocolVersions: string[];
|
|
13
|
+
serverCapabilities: Record<string, any>;
|
|
14
|
+
serverName: string;
|
|
15
|
+
serverVersion: string;
|
|
16
|
+
instructions: string;
|
|
17
|
+
maxPaginationLength: number;
|
|
18
|
+
defaultPaginationLength: number;
|
|
19
|
+
tools: ToolList;
|
|
20
|
+
resources: ResourceList;
|
|
21
|
+
prompts: PromptList;
|
|
22
|
+
request: McpRequest;
|
|
23
|
+
response: McpResponse;
|
|
24
|
+
constructor(options: ServerContextOptions);
|
|
25
|
+
getPerPage(requestedPerPage?: number): number;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/server/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,UAAU;IACtD,yBAAyB,EAAE,MAAM,EAAE,CAAA;IACnC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAA;IACf,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,UAAU,CAAA;IACnB,QAAQ,EAAE,WAAW,CAAA;gBAET,OAAO,EAAE,oBAAoB;IAelC,UAAU,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;CAGrD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Request from '../request.js';
|
|
2
|
+
import McpResponse from '../response.js';
|
|
3
|
+
export default class ServerContext {
|
|
4
|
+
supportedProtocolVersions;
|
|
5
|
+
serverCapabilities;
|
|
6
|
+
serverName;
|
|
7
|
+
serverVersion;
|
|
8
|
+
instructions;
|
|
9
|
+
maxPaginationLength;
|
|
10
|
+
defaultPaginationLength;
|
|
11
|
+
tools;
|
|
12
|
+
resources;
|
|
13
|
+
prompts;
|
|
14
|
+
request;
|
|
15
|
+
response;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.supportedProtocolVersions = options.supportedProtocolVersions;
|
|
18
|
+
this.serverCapabilities = options.serverCapabilities;
|
|
19
|
+
this.serverName = options.serverName;
|
|
20
|
+
this.serverVersion = options.serverVersion;
|
|
21
|
+
this.instructions = options.instructions;
|
|
22
|
+
this.maxPaginationLength = options.maxPaginationLength;
|
|
23
|
+
this.defaultPaginationLength = options.defaultPaginationLength;
|
|
24
|
+
this.tools = options.tools;
|
|
25
|
+
this.resources = options.resources;
|
|
26
|
+
this.prompts = options.prompts;
|
|
27
|
+
this.request = new Request(options.jsonRpcRequest);
|
|
28
|
+
this.response = new McpResponse();
|
|
29
|
+
}
|
|
30
|
+
getPerPage(requestedPerPage) {
|
|
31
|
+
return Math.min(requestedPerPage ?? this.defaultPaginationLength, this.maxPaginationLength);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
8
|
+
export default class McpController {
|
|
9
|
+
post(ctx: HttpContext): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=mcp_controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp_controller.d.ts","sourceRoot":"","sources":["../../../../src/server/controllers/mcp_controller.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAGtD,MAAM,CAAC,OAAO,OAAO,aAAa;IAC1B,IAAI,CAAC,GAAG,EAAE,WAAW;CAO5B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import HttpTransport from '../transports/http_transport.js';
|
|
8
|
+
export default class McpController {
|
|
9
|
+
async post(ctx) {
|
|
10
|
+
const body = ctx.request.body();
|
|
11
|
+
const mcp = await ctx.containerResolver.make('jrmc.mcp');
|
|
12
|
+
await mcp.connect(new HttpTransport(ctx));
|
|
13
|
+
await mcp.handle(body);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonRpcResponse } from '../../types/response.js';
|
|
2
|
+
export default class JsonRpcException extends Error {
|
|
3
|
+
protected code: number;
|
|
4
|
+
protected requestId: string | number;
|
|
5
|
+
protected data?: Record<string, unknown> | undefined;
|
|
6
|
+
constructor(message: string, code: number, requestId: string | number, data?: Record<string, unknown> | undefined);
|
|
7
|
+
toJsonRpcResponse(): JsonRpcResponse;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=jsonrpc_exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc_exception.d.ts","sourceRoot":"","sources":["../../../../src/server/exceptions/jsonrpc_exception.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAI9D,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,KAAK;IAG/C,SAAS,CAAC,IAAI,EAAE,MAAM;IACtB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IACpC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAHxC,OAAO,EAAE,MAAM,EACL,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;IAM1C,iBAAiB,IAAI,eAAe;CAUrC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Response from '../../response.js';
|
|
2
|
+
export default class JsonRpcException extends Error {
|
|
3
|
+
code;
|
|
4
|
+
requestId;
|
|
5
|
+
data;
|
|
6
|
+
constructor(message, code, requestId, data) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.requestId = requestId;
|
|
10
|
+
this.data = data;
|
|
11
|
+
}
|
|
12
|
+
toJsonRpcResponse() {
|
|
13
|
+
return Response.toJsonRpc({
|
|
14
|
+
id: this.requestId,
|
|
15
|
+
error: {
|
|
16
|
+
code: this.code,
|
|
17
|
+
message: this.message,
|
|
18
|
+
data: this.data,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class CallTool implements Method {
|
|
10
|
+
handle(ctx: McpContext): Promise<import("../../types/response.js").JsonRpcResponse>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=call_tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call_tool.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/call_tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMxD,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,MAAM;IACvC,MAAM,CAAC,GAAG,EAAE,UAAU;CAyC7B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 Response from '../../response.js';
|
|
10
|
+
export default class CallTool {
|
|
11
|
+
async handle(ctx) {
|
|
12
|
+
if (ctx.request.method !== 'tools/call') {
|
|
13
|
+
throw new JsonRpcException(`The request method ${ctx.request.method} is not valid for tools/call handler.`, ErrorCode.MethodNotFound, ctx.request.id);
|
|
14
|
+
}
|
|
15
|
+
const params = ctx.request.params;
|
|
16
|
+
if (!params?.name) {
|
|
17
|
+
throw new JsonRpcException(`The tool name is required.`, ErrorCode.InvalidParams, ctx.request.id);
|
|
18
|
+
}
|
|
19
|
+
const item = Object.keys(ctx.tools).find((key) => key === params.name);
|
|
20
|
+
if (!item) {
|
|
21
|
+
throw new JsonRpcException(`The tool ${params.name} was not found.`, ErrorCode.MethodNotFound, ctx.request.id);
|
|
22
|
+
}
|
|
23
|
+
const { default: Tool } = await import(ctx.tools[item]);
|
|
24
|
+
ctx.args = params.arguments ?? {};
|
|
25
|
+
const tool = new Tool(ctx);
|
|
26
|
+
const data = await tool.handle(ctx);
|
|
27
|
+
let result;
|
|
28
|
+
let error;
|
|
29
|
+
if (Array.isArray(data)) {
|
|
30
|
+
result = { content: data };
|
|
31
|
+
}
|
|
32
|
+
else if (data.code) {
|
|
33
|
+
error = data;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result = { content: [data] };
|
|
37
|
+
}
|
|
38
|
+
return Response.toJsonRpc({ id: ctx.request.id, result, error });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class GetPrompt implements Method {
|
|
10
|
+
handle(ctx: McpContext): import("../../types/response.js").JsonRpcResponse;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=get_prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_prompt.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/get_prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,OAAO,SAAU,YAAW,MAAM;IAC9C,MAAM,CAAC,GAAG,EAAE,UAAU;CAGvB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Response from '../../response.js';
|
|
8
|
+
export default class GetPrompt {
|
|
9
|
+
handle(ctx) {
|
|
10
|
+
return Response.toJsonRpc({ id: ctx.request.id });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class Initialize implements Method {
|
|
10
|
+
handle(ctx: McpContext): import("../../types/response.js").JsonRpcResponse;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=initialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/initialize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMxD,MAAM,CAAC,OAAO,OAAO,UAAW,YAAW,MAAM;IAC/C,MAAM,CAAC,GAAG,EAAE,UAAU;CA4BvB"}
|
|
@@ -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 Response from '../../response.js';
|
|
10
|
+
export default class Initialize {
|
|
11
|
+
handle(ctx) {
|
|
12
|
+
if (ctx.request.method !== 'initialize') {
|
|
13
|
+
throw new JsonRpcException('Invalid request method for initialize handler', ErrorCode.InvalidRequest, ctx.request.id);
|
|
14
|
+
}
|
|
15
|
+
const requestedVersion = ctx.request.params.protocolVersion ?? null;
|
|
16
|
+
if (requestedVersion !== null && !ctx.supportedProtocolVersions.includes(requestedVersion)) {
|
|
17
|
+
throw new JsonRpcException('Unsupported protocol version', ErrorCode.InvalidRequest, ctx.request.id);
|
|
18
|
+
}
|
|
19
|
+
const protocolVersion = requestedVersion ?? ctx.supportedProtocolVersions[0];
|
|
20
|
+
const result = {
|
|
21
|
+
protocolVersion,
|
|
22
|
+
capabilities: ctx.serverCapabilities,
|
|
23
|
+
serverInfo: {
|
|
24
|
+
name: ctx.serverName,
|
|
25
|
+
version: ctx.serverVersion,
|
|
26
|
+
},
|
|
27
|
+
instructions: ctx.instructions,
|
|
28
|
+
};
|
|
29
|
+
return Response.toJsonRpc({ id: ctx.request.id, result });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class ListPrompts implements Method {
|
|
10
|
+
handle(ctx: McpContext): import("../../types/response.js").JsonRpcResponse;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=list_prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list_prompts.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/list_prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,OAAO,WAAY,YAAW,MAAM;IAChD,MAAM,CAAC,GAAG,EAAE,UAAU;CAIvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Response from '../../response.js';
|
|
8
|
+
export default class ListPrompts {
|
|
9
|
+
handle(ctx) {
|
|
10
|
+
const promptsArray = Object.values(ctx.prompts);
|
|
11
|
+
return Response.toJsonRpc({ id: ctx.request.id, result: { prompts: promptsArray } });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class ListResources implements Method {
|
|
10
|
+
handle(ctx: McpContext): import("../../types/response.js").JsonRpcResponse;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=list_resources.d.ts.map
|
|
@@ -0,0 +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,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,MAAM;IAClD,MAAM,CAAC,GAAG,EAAE,UAAU;CAIvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Response from '../../response.js';
|
|
8
|
+
export default class ListResources {
|
|
9
|
+
handle(ctx) {
|
|
10
|
+
const resourcesArray = Object.values(ctx.resources);
|
|
11
|
+
return Response.toJsonRpc({ id: ctx.request.id, result: { resources: resourcesArray } });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class ListTools implements Method {
|
|
10
|
+
handle(ctx: McpContext): Promise<import("../../types/response.js").JsonRpcResponse>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=list_tools.d.ts.map
|
|
@@ -0,0 +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,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAOxD,MAAM,CAAC,OAAO,OAAO,SAAU,YAAW,MAAM;IACxC,MAAM,CAAC,GAAG,EAAE,UAAU;CA6C7B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 ListTools {
|
|
12
|
+
async handle(ctx) {
|
|
13
|
+
let nextCursor;
|
|
14
|
+
const paginator = new CursorPaginator(Object.values(ctx.tools), ctx.getPerPage(), ctx.request.params?.cursor);
|
|
15
|
+
const paginatedTools = paginator.paginate('tools');
|
|
16
|
+
const tools = await Promise.all(paginatedTools['tools'].map(async (filepath) => {
|
|
17
|
+
try {
|
|
18
|
+
const { default: Tool } = await import(filepath);
|
|
19
|
+
const tool = new Tool();
|
|
20
|
+
const schema = tool.schema
|
|
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
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new JsonRpcException(`Error listing tool`, ErrorCode.InternalError, ctx.request.id, { error });
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
if (paginatedTools.nextCursor) {
|
|
42
|
+
nextCursor = paginatedTools.nextCursor;
|
|
43
|
+
}
|
|
44
|
+
return Response.toJsonRpc({ id: ctx.request.id, result: { tools, nextCursor } });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class Ping implements Method {
|
|
10
|
+
handle(ctx: McpContext): import("../../types/response.js").JsonRpcResponse;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/server/methods/ping.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,MAAM;IACzC,MAAM,CAAC,GAAG,EAAE,UAAU;CAGvB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Response from '../../response.js';
|
|
8
|
+
export default class Ping {
|
|
9
|
+
handle(ctx) {
|
|
10
|
+
return Response.toJsonRpc({ id: ctx.request.id });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Method } from '../../types/method.js';
|
|
8
|
+
import type { McpContext } from '../../types/context.js';
|
|
9
|
+
export default class ReadResource implements Method {
|
|
10
|
+
handle(ctx: McpContext): import("../../types/response.js").JsonRpcResponse;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=read_resource.d.ts.map
|
|
@@ -0,0 +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,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,MAAM;IACjD,MAAM,CAAC,GAAG,EAAE,UAAU;CAGvB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-mcp
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Response from '../../response.js';
|
|
8
|
+
export default class ReadResource {
|
|
9
|
+
handle(ctx) {
|
|
10
|
+
return Response.toJsonRpc({ id: ctx.request.id });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class CursorPaginator {
|
|
2
|
+
private items;
|
|
3
|
+
private perPage;
|
|
4
|
+
private cursor?;
|
|
5
|
+
constructor(items: unknown[], perPage: number, cursor?: string | undefined);
|
|
6
|
+
paginate(key?: string): {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
protected getStartOffsetFromCursor(): number;
|
|
10
|
+
protected createCursor(offset: number): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=cursor_paginator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor_paginator.d.ts","sourceRoot":"","sources":["../../../../src/server/pagination/cursor_paginator.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAExB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM,CAAC;gBAFP,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,YAAA;IAGlB,QAAQ,CAAC,GAAG,GAAE,MAAgB,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE;IAkBlE,SAAS,CAAC,wBAAwB;IA0BlC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM;CAGtC"}
|