@webda/mcp 0.0.0-stage → 4.0.0-beta.4
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 +166 -0
- package/README.md +168 -2
- package/lib/auth.d.ts +27 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +14 -0
- package/lib/auth.js.map +1 -0
- package/lib/bridge.d.ts +26 -0
- package/lib/bridge.d.ts.map +1 -0
- package/lib/bridge.js +72 -0
- package/lib/bridge.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/invoke.d.ts +108 -0
- package/lib/invoke.d.ts.map +1 -0
- package/lib/invoke.js +180 -0
- package/lib/invoke.js.map +1 -0
- package/lib/mcpservice.service.d.ts +194 -0
- package/lib/mcpservice.service.d.ts.map +1 -0
- package/lib/mcpservice.service.js +463 -0
- package/lib/mcpservice.service.js.map +1 -0
- package/lib/resources.d.ts +86 -0
- package/lib/resources.d.ts.map +1 -0
- package/lib/resources.js +125 -0
- package/lib/resources.js.map +1 -0
- package/lib/schema.d.ts +23 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +69 -0
- package/lib/schema.js.map +1 -0
- package/lib/server.d.ts +54 -0
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +167 -0
- package/lib/server.js.map +1 -0
- package/lib/sessions.d.ts +78 -0
- package/lib/sessions.d.ts.map +1 -0
- package/lib/sessions.js +99 -0
- package/lib/sessions.js.map +1 -0
- package/lib/tools.d.ts +62 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tools.js +126 -0
- package/lib/tools.js.map +1 -0
- package/package.json +47 -3
- package/webda.module.json +211 -0
package/lib/tools.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { OperationDefinition } from "@webda/core";
|
|
2
|
+
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { SchemaResolver } from "./schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* A tool exposed over MCP and the operation backing it
|
|
6
|
+
*/
|
|
7
|
+
export interface ToolEntry {
|
|
8
|
+
/**
|
|
9
|
+
* MCP tool definition
|
|
10
|
+
*/
|
|
11
|
+
tool: Tool;
|
|
12
|
+
/**
|
|
13
|
+
* Webda operation id
|
|
14
|
+
*/
|
|
15
|
+
operationId: string;
|
|
16
|
+
/**
|
|
17
|
+
* True when the operation input is not an object and is wrapped as `{ value }`
|
|
18
|
+
*/
|
|
19
|
+
wrapped: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Map a Webda operation to an MCP tool
|
|
23
|
+
* @param id - operation id, used as the tool name
|
|
24
|
+
* @param op - operation definition
|
|
25
|
+
* @param resolve - schema resolver
|
|
26
|
+
* @returns the tool entry, or undefined when the operation must not be exposed
|
|
27
|
+
*/
|
|
28
|
+
export declare function operationToTool(id: string, op: OperationDefinition, resolve: SchemaResolver): ToolEntry | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Fingerprint of the registered operation ids, to detect runtime registrations
|
|
31
|
+
* @param ops - operations map
|
|
32
|
+
* @returns a stable string for the set of ids
|
|
33
|
+
*/
|
|
34
|
+
export declare function operationsFingerprint(ops: Record<string, OperationDefinition>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Registry of MCP tools built from operations
|
|
37
|
+
*/
|
|
38
|
+
export declare class ToolRegistry {
|
|
39
|
+
protected resolve: SchemaResolver;
|
|
40
|
+
protected entries: Map<string, ToolEntry>;
|
|
41
|
+
/**
|
|
42
|
+
* @param resolve - schema resolver used to build input/output schemas
|
|
43
|
+
*/
|
|
44
|
+
constructor(resolve: SchemaResolver);
|
|
45
|
+
/**
|
|
46
|
+
* Rebuild the registry from operations
|
|
47
|
+
* @param ops - visible operations of the transport
|
|
48
|
+
*/
|
|
49
|
+
build(ops: Record<string, OperationDefinition>): void;
|
|
50
|
+
/**
|
|
51
|
+
* All tool entries, sorted by name
|
|
52
|
+
* @returns tool entries
|
|
53
|
+
*/
|
|
54
|
+
list(): ToolEntry[];
|
|
55
|
+
/**
|
|
56
|
+
* Find a tool by name
|
|
57
|
+
* @param name - tool name
|
|
58
|
+
* @returns the entry or undefined
|
|
59
|
+
*/
|
|
60
|
+
get(name: string): ToolEntry | undefined;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAA4B,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAiCD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,mBAAmB,EAAE,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS,CAoCnH;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,MAAM,CAEtF;AAED;;GAEG;AACH,qBAAa,YAAY;IAMX,SAAS,CAAC,OAAO,EAAE,cAAc;IAL7C,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAa;IAEtD;;OAEG;IACH,YAAsB,OAAO,EAAE,cAAc,EAAI;IAEjD;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAQpD;IAED;;;OAGG;IACH,IAAI,IAAI,SAAS,EAAE,CAElB;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAEvC;CACF"}
|
package/lib/tools.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { inlineSchema } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve an operation schema reference ("void", "Name" or optional "Name?")
|
|
4
|
+
* @param ref - the operation input/output reference
|
|
5
|
+
* @param resolve - schema resolver
|
|
6
|
+
* @returns the inlined schema, or undefined for "void"/unknown
|
|
7
|
+
*/
|
|
8
|
+
function resolveRef(ref, resolve) {
|
|
9
|
+
if (!ref || ref === "void") {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const optional = ref.endsWith("?");
|
|
13
|
+
const raw = resolve(optional ? ref.slice(0, -1) : ref);
|
|
14
|
+
if (!raw) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const schema = inlineSchema(raw, resolve);
|
|
18
|
+
if (optional) {
|
|
19
|
+
delete schema.required;
|
|
20
|
+
}
|
|
21
|
+
return schema;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether a schema describes a JSON object
|
|
25
|
+
* @param schema - the schema
|
|
26
|
+
* @returns true for object schemas
|
|
27
|
+
*/
|
|
28
|
+
function isObjectSchema(schema) {
|
|
29
|
+
return !!schema && (schema.type === "object" || (schema.type === undefined && schema.properties !== undefined));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Map a Webda operation to an MCP tool
|
|
33
|
+
* @param id - operation id, used as the tool name
|
|
34
|
+
* @param op - operation definition
|
|
35
|
+
* @param resolve - schema resolver
|
|
36
|
+
* @returns the tool entry, or undefined when the operation must not be exposed
|
|
37
|
+
*/
|
|
38
|
+
export function operationToTool(id, op, resolve) {
|
|
39
|
+
if (op.hidden || op.mcp === false) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const hints = op.mcp || {};
|
|
43
|
+
const input = op.input === undefined || op.input === "void" ? undefined : resolveRef(op.input, resolve);
|
|
44
|
+
let inputSchema;
|
|
45
|
+
let wrapped = false;
|
|
46
|
+
if (op.input === undefined || op.input === "void") {
|
|
47
|
+
inputSchema = { type: "object", properties: {} };
|
|
48
|
+
}
|
|
49
|
+
else if (!input) {
|
|
50
|
+
inputSchema = { type: "object" };
|
|
51
|
+
}
|
|
52
|
+
else if (isObjectSchema(input)) {
|
|
53
|
+
inputSchema = { ...input, type: "object" };
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
inputSchema = { type: "object", properties: { value: input } };
|
|
57
|
+
if (!op.input.endsWith("?")) {
|
|
58
|
+
inputSchema.required = ["value"];
|
|
59
|
+
}
|
|
60
|
+
wrapped = true;
|
|
61
|
+
}
|
|
62
|
+
const description = [op.summary, op.description].filter(Boolean).join("\n\n") || `Call operation ${id}`;
|
|
63
|
+
const tool = {
|
|
64
|
+
name: id,
|
|
65
|
+
description: op.deprecated ? `${description} (deprecated)` : description,
|
|
66
|
+
inputSchema: inputSchema,
|
|
67
|
+
annotations: {
|
|
68
|
+
readOnlyHint: hints.readOnly ?? (op.rest !== false && op.rest?.method === "get" ? true : /\.(Get|Query)$/.test(id)),
|
|
69
|
+
destructiveHint: hints.destructive ?? (op.rest !== false && op.rest?.method === "delete" ? true : id.endsWith(".Delete"))
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if (hints.title) {
|
|
73
|
+
tool.title = hints.title;
|
|
74
|
+
}
|
|
75
|
+
return { tool, operationId: id, wrapped };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Fingerprint of the registered operation ids, to detect runtime registrations
|
|
79
|
+
* @param ops - operations map
|
|
80
|
+
* @returns a stable string for the set of ids
|
|
81
|
+
*/
|
|
82
|
+
export function operationsFingerprint(ops) {
|
|
83
|
+
return Object.keys(ops).sort().join("|");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Registry of MCP tools built from operations
|
|
87
|
+
*/
|
|
88
|
+
export class ToolRegistry {
|
|
89
|
+
resolve;
|
|
90
|
+
entries = new Map();
|
|
91
|
+
/**
|
|
92
|
+
* @param resolve - schema resolver used to build input/output schemas
|
|
93
|
+
*/
|
|
94
|
+
constructor(resolve) {
|
|
95
|
+
this.resolve = resolve;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rebuild the registry from operations
|
|
99
|
+
* @param ops - visible operations of the transport
|
|
100
|
+
*/
|
|
101
|
+
build(ops) {
|
|
102
|
+
this.entries.clear();
|
|
103
|
+
for (const [id, op] of Object.entries(ops)) {
|
|
104
|
+
const entry = operationToTool(id, op, this.resolve);
|
|
105
|
+
if (entry) {
|
|
106
|
+
this.entries.set(id, entry);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* All tool entries, sorted by name
|
|
112
|
+
* @returns tool entries
|
|
113
|
+
*/
|
|
114
|
+
list() {
|
|
115
|
+
return [...this.entries.values()].sort((a, b) => a.tool.name.localeCompare(b.tool.name));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Find a tool by name
|
|
119
|
+
* @param name - tool name
|
|
120
|
+
* @returns the entry or undefined
|
|
121
|
+
*/
|
|
122
|
+
get(name) {
|
|
123
|
+
return this.entries.get(name);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=tools.js.map
|
package/lib/tools.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA8B,MAAM,aAAa,CAAC;AAoBvE;;;;;GAKG;AACH,SAAS,UAAU,CAAC,GAAuB,EAAE,OAAuB;IAClE,IAAI,CAAC,GAAG,IAAI,GAAG,KAA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H,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webda/mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
|
+
"description": "MCP transport for Webda.io — exposes operations as Model Context Protocol tools and resources",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
10
|
+
"@webda/workout": "4.0.0-beta.3"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"@webda/core": "^4.0.0-beta.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
17
|
+
"typescript": "7.1.0-dev.20260929.1",
|
|
18
|
+
"vite": "^6.0.0",
|
|
19
|
+
"vitest": "^4.0.0",
|
|
20
|
+
"@webda/compiler": "^4.0.0-beta.4",
|
|
21
|
+
"@webda/core": "^4.0.0-beta.4",
|
|
22
|
+
"@webda/test": "^4.0.0-beta.3",
|
|
23
|
+
"@webda/utils": "^4.0.0-beta.4"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib",
|
|
27
|
+
"webda.module.json"
|
|
28
|
+
],
|
|
29
|
+
"webda": {
|
|
30
|
+
"namespace": "Webda",
|
|
31
|
+
"capabilities": {
|
|
32
|
+
"mcp": "Webda/McpService"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"license": "LGPL-3.0-only",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/loopingz/webda.io.git",
|
|
42
|
+
"directory": "packages/mcp"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "webdac build",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"lint": "eslint src/",
|
|
48
|
+
"lint:fix": "eslint --fix src/"
|
|
49
|
+
}
|
|
6
50
|
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://webda.io/schemas/webda.module.v4.json",
|
|
3
|
+
"beans": {},
|
|
4
|
+
"deployers": {},
|
|
5
|
+
"moddas": {
|
|
6
|
+
"Webda/McpService": {
|
|
7
|
+
"Import": "lib/mcpservice.service:McpService",
|
|
8
|
+
"Schema": {
|
|
9
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"definitions": {
|
|
12
|
+
"resources#2": {
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"models": {
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"type": "array"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"type": "object"
|
|
23
|
+
},
|
|
24
|
+
"stdio": {
|
|
25
|
+
"additionalProperties": false,
|
|
26
|
+
"description": "stdio defaults",
|
|
27
|
+
"properties": {
|
|
28
|
+
"user": {
|
|
29
|
+
"description": "Default user for `webda mcp`",
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"type": "object"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"description": "Parameters for the MCP transport",
|
|
37
|
+
"properties": {
|
|
38
|
+
"allowedHosts": {
|
|
39
|
+
"default": [
|
|
40
|
+
"localhost",
|
|
41
|
+
"127.0.0.1",
|
|
42
|
+
"::1"
|
|
43
|
+
],
|
|
44
|
+
"description": "Hostnames (any port) accepted in the request Host, against DNS rebinding;\n\"*\" disables the check",
|
|
45
|
+
"items": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
},
|
|
48
|
+
"type": "array"
|
|
49
|
+
},
|
|
50
|
+
"allowedOrigins": {
|
|
51
|
+
"default": [],
|
|
52
|
+
"description": "Extra Origin values accepted besides the request's own origin",
|
|
53
|
+
"items": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"type": "array"
|
|
57
|
+
},
|
|
58
|
+
"authenticator": {
|
|
59
|
+
"description": "Name of a service implementing McpAuthenticator; default uses the Webda session",
|
|
60
|
+
"type": "string"
|
|
61
|
+
},
|
|
62
|
+
"maxOutputBytes": {
|
|
63
|
+
"default": 1048576,
|
|
64
|
+
"description": "Larger tool/resource outputs are truncated",
|
|
65
|
+
"type": "number"
|
|
66
|
+
},
|
|
67
|
+
"maxSessions": {
|
|
68
|
+
"default": 1000,
|
|
69
|
+
"description": "Maximum number of concurrent MCP HTTP sessions; at the limit the least\nrecently used session is closed to make room for a new one",
|
|
70
|
+
"type": "number"
|
|
71
|
+
},
|
|
72
|
+
"operations": {
|
|
73
|
+
"default": [
|
|
74
|
+
"*"
|
|
75
|
+
],
|
|
76
|
+
"description": "List of operations to include/exclude\nSupports wildcards and negation: [\"*\", \"!User.Delete\"]",
|
|
77
|
+
"items": {
|
|
78
|
+
"type": "string"
|
|
79
|
+
},
|
|
80
|
+
"type": "array"
|
|
81
|
+
},
|
|
82
|
+
"resources": {
|
|
83
|
+
"anyOf": [
|
|
84
|
+
{
|
|
85
|
+
"const": false,
|
|
86
|
+
"type": "boolean"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"$ref": "#/definitions/resources%232"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"default": {
|
|
93
|
+
"models": [
|
|
94
|
+
"*"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"description": "Models exposed as resources (short ids or \"*\"); false disables resources"
|
|
98
|
+
},
|
|
99
|
+
"serverName": {
|
|
100
|
+
"description": "Server name announced to clients (defaults to the application package name)",
|
|
101
|
+
"type": "string"
|
|
102
|
+
},
|
|
103
|
+
"serverVersion": {
|
|
104
|
+
"description": "Server version announced to clients (defaults to the application package version)",
|
|
105
|
+
"type": "string"
|
|
106
|
+
},
|
|
107
|
+
"sessionTimeout": {
|
|
108
|
+
"default": 1800,
|
|
109
|
+
"description": "Seconds of inactivity before an MCP session is evicted",
|
|
110
|
+
"type": "number"
|
|
111
|
+
},
|
|
112
|
+
"stdio": {
|
|
113
|
+
"$ref": "#/definitions/stdio",
|
|
114
|
+
"description": "stdio defaults"
|
|
115
|
+
},
|
|
116
|
+
"type": {
|
|
117
|
+
"description": "Type of the service",
|
|
118
|
+
"type": "string"
|
|
119
|
+
},
|
|
120
|
+
"url": {
|
|
121
|
+
"anyOf": [
|
|
122
|
+
{
|
|
123
|
+
"type": "string"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"const": false,
|
|
127
|
+
"type": "boolean"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"default": "/mcp",
|
|
131
|
+
"description": "HTTP endpoint; false disables HTTP (stdio only)"
|
|
132
|
+
},
|
|
133
|
+
"openapi": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"additionalProperties": true
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"required": [
|
|
139
|
+
"type"
|
|
140
|
+
],
|
|
141
|
+
"type": "object",
|
|
142
|
+
"title": "McpService"
|
|
143
|
+
},
|
|
144
|
+
"Configuration": "lib/mcpservice.service:McpServiceParameters",
|
|
145
|
+
"commands": {
|
|
146
|
+
"mcp": {
|
|
147
|
+
"description": "Serve operations as MCP tools over stdio",
|
|
148
|
+
"method": "mcp",
|
|
149
|
+
"args": {
|
|
150
|
+
"user": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"default": ""
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"requires": [
|
|
156
|
+
"mcp"
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"models": {},
|
|
163
|
+
"schemas": {
|
|
164
|
+
"Webda/BinaryFile": {
|
|
165
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
166
|
+
"WebdaSchema": true,
|
|
167
|
+
"additionalProperties": false,
|
|
168
|
+
"description": "Represent a file to store",
|
|
169
|
+
"properties": {
|
|
170
|
+
"challenge": {
|
|
171
|
+
"description": "Will be computed by the service\n\nhash of the content prefixed by 'WEBDA'",
|
|
172
|
+
"type": "string"
|
|
173
|
+
},
|
|
174
|
+
"hash": {
|
|
175
|
+
"description": "Will be computed by the service\n\nhash of the content",
|
|
176
|
+
"type": "string"
|
|
177
|
+
},
|
|
178
|
+
"metadata": {
|
|
179
|
+
"description": "Metadatas stored along with the binary"
|
|
180
|
+
},
|
|
181
|
+
"mimetype": {
|
|
182
|
+
"description": "Mimetype of the binary",
|
|
183
|
+
"type": "string"
|
|
184
|
+
},
|
|
185
|
+
"name": {
|
|
186
|
+
"description": "Current name",
|
|
187
|
+
"type": "string"
|
|
188
|
+
},
|
|
189
|
+
"originalname": {
|
|
190
|
+
"description": "Original name",
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
"size": {
|
|
194
|
+
"description": "Size of the binary",
|
|
195
|
+
"type": "number"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"required": [
|
|
199
|
+
"mimetype",
|
|
200
|
+
"name",
|
|
201
|
+
"size"
|
|
202
|
+
],
|
|
203
|
+
"type": "object",
|
|
204
|
+
"title": "BinaryFile"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"behaviors": {},
|
|
208
|
+
"capabilities": {
|
|
209
|
+
"mcp": "Webda/McpService"
|
|
210
|
+
}
|
|
211
|
+
}
|