@abgov/adsp-sdk-mcp-server 1.31.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -6
- package/assets/api-specs/calendar-service.json +1 -1
- package/assets/capabilities.json +1709 -0
- package/package.json +1 -1
- package/provenance.json +3 -3
- package/src/capabilities/catalog.d.ts +44 -0
- package/src/capabilities/catalog.js +8 -0
- package/src/capabilities/catalog.js.map +1 -0
- package/src/capabilities/findServices.d.ts +43 -0
- package/src/capabilities/findServices.js +182 -0
- package/src/capabilities/findServices.js.map +1 -0
- package/src/instructions.js +3 -3
- package/src/instructions.js.map +1 -1
- package/src/server.d.ts +2 -0
- package/src/server.js +13 -6
- package/src/server.js.map +1 -1
- package/src/tools/registerFindServicesTool.d.ts +126 -0
- package/src/tools/registerFindServicesTool.js +152 -0
- package/src/tools/registerFindServicesTool.js.map +1 -0
- package/src/tools/types.d.ts +5 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FIND_SERVICES_OUTPUT_SCHEMA = void 0;
|
|
4
|
+
exports.createFindServicesTool = createFindServicesTool;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const findServices_1 = require("../capabilities/findServices");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const MAX_NEEDS = 50;
|
|
9
|
+
const FindArgs = zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
need: zod_1.z.string().trim().min(1).optional(),
|
|
12
|
+
needs: zod_1.z.array(zod_1.z.string().trim().min(1)).min(1).max(MAX_NEEDS).optional(),
|
|
13
|
+
response_format: zod_1.z.enum(['concise', 'detailed']).optional(),
|
|
14
|
+
})
|
|
15
|
+
.refine(({ need, needs }) => Boolean(need) !== Boolean(needs), { message: 'Pass exactly one of need or needs.' });
|
|
16
|
+
const MATCH_PROPERTIES = {
|
|
17
|
+
service: { type: 'string', description: 'Service id, e.g. "file-service".' },
|
|
18
|
+
fit: { type: 'string', enum: ['strong', 'partial', 'weak'] },
|
|
19
|
+
reason: { type: 'string', description: 'The catalog sentence that best explains the match.' },
|
|
20
|
+
name: { type: 'string' },
|
|
21
|
+
dependsOn: { type: 'array', items: { type: 'string' }, description: 'Services to set up first.' },
|
|
22
|
+
registration: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
description: 'How a service built with @abgov/adsp-service-sdk configures it: the ServiceRegistration fields written to ' +
|
|
25
|
+
'this service, and the serviceId to use in a serviceConfigurations entry when the service takes ' +
|
|
26
|
+
'configuration from yours (check that with get_service_configuration_schema).',
|
|
27
|
+
properties: {
|
|
28
|
+
fields: { type: 'array', items: { type: 'string' } },
|
|
29
|
+
serviceConfigurations: { type: 'string' },
|
|
30
|
+
},
|
|
31
|
+
required: ['fields', 'serviceConfigurations'],
|
|
32
|
+
},
|
|
33
|
+
doc: { type: 'string', description: 'Service guide path, for read_adsp_doc.' },
|
|
34
|
+
fitQuestions: { type: 'array', items: { type: 'string' } },
|
|
35
|
+
risks: { type: 'array', items: { type: 'string' } },
|
|
36
|
+
specialist: {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
description: 'False when project-planner-service has no specialist for the service, so it has no fit questions.',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const KNOWN_GAP_PROPERTIES = {
|
|
42
|
+
requirement: { type: 'string' },
|
|
43
|
+
reason: { type: 'string' },
|
|
44
|
+
suggestedApproach: { type: 'string' },
|
|
45
|
+
};
|
|
46
|
+
exports.FIND_SERVICES_OUTPUT_SCHEMA = {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
results: {
|
|
50
|
+
type: 'array',
|
|
51
|
+
items: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
need: { type: 'string' },
|
|
55
|
+
ask: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
description: 'True when no service is a strong fit or more than one is. Ask the user instead of choosing.',
|
|
58
|
+
},
|
|
59
|
+
fitQuestions: { type: 'array', items: { type: 'string' }, description: 'What to ask when ask is true.' },
|
|
60
|
+
matches: {
|
|
61
|
+
type: 'array',
|
|
62
|
+
items: { type: 'object', properties: MATCH_PROPERTIES, required: ['service', 'fit', 'reason'] },
|
|
63
|
+
},
|
|
64
|
+
noMatch: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {
|
|
67
|
+
need: { type: 'string' },
|
|
68
|
+
reason: { type: 'string' },
|
|
69
|
+
knownGap: { type: 'object', properties: KNOWN_GAP_PROPERTIES, required: ['requirement', 'reason', 'suggestedApproach'] },
|
|
70
|
+
},
|
|
71
|
+
required: ['need', 'reason'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
required: ['need', 'ask', 'fitQuestions', 'matches'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
required: ['results'],
|
|
79
|
+
};
|
|
80
|
+
function formatMatch({ service, fit, reason }, format) {
|
|
81
|
+
if (format === 'concise') {
|
|
82
|
+
return { service: service.id, fit, reason };
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
service: service.id,
|
|
86
|
+
fit,
|
|
87
|
+
reason,
|
|
88
|
+
name: service.name,
|
|
89
|
+
dependsOn: service.dependsOn,
|
|
90
|
+
registration: { fields: service.registrationFields, serviceConfigurations: `urn:ads:platform:${service.id}` },
|
|
91
|
+
doc: service.doc,
|
|
92
|
+
fitQuestions: service.fitQuestions,
|
|
93
|
+
risks: service.risks,
|
|
94
|
+
specialist: service.specialist,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function formatResult({ need, matches, ask, fitQuestions, noMatch }, format) {
|
|
98
|
+
return {
|
|
99
|
+
need,
|
|
100
|
+
ask,
|
|
101
|
+
fitQuestions,
|
|
102
|
+
matches: matches.map((match) => formatMatch(match, format)),
|
|
103
|
+
...(noMatch && { noMatch: { need, ...noMatch } }),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createFindServicesTool(catalog) {
|
|
107
|
+
let finder;
|
|
108
|
+
return [
|
|
109
|
+
{
|
|
110
|
+
name: 'find_adsp_services',
|
|
111
|
+
annotations: types_1.OFFLINE_TOOL_ANNOTATIONS,
|
|
112
|
+
description: 'Match a product need, described in your own words, to the ADSP services that provide it, ranked by fit. ' +
|
|
113
|
+
'Pass one need, or several requirement lines as needs. Each match has a fit level (strong, partial or ' +
|
|
114
|
+
'weak) and the reason it fits; response_format "detailed" adds dependencies, how to register with the ' +
|
|
115
|
+
'service from @abgov/adsp-service-sdk, the guide to read next, fit questions and risks. When ask is true, ' +
|
|
116
|
+
'ask the user the fitQuestions before choosing. A noMatch entry records that no ADSP service covers the ' +
|
|
117
|
+
'need, with a suggested approach when the gap is known. Answers from a catalog bundled at build time.',
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: 'object',
|
|
120
|
+
properties: {
|
|
121
|
+
need: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
description: 'One need, e.g. "applicants attach supporting documents to an application".',
|
|
124
|
+
},
|
|
125
|
+
needs: {
|
|
126
|
+
type: 'array',
|
|
127
|
+
items: { type: 'string' },
|
|
128
|
+
description: `Several needs, such as requirement lines, matched one by one (at most ${MAX_NEEDS}). Pass this or need.`,
|
|
129
|
+
},
|
|
130
|
+
response_format: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
enum: ['concise', 'detailed'],
|
|
133
|
+
description: '"concise" (default): service, fit and reason. "detailed": every field.',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
outputSchema: exports.FIND_SERVICES_OUTPUT_SCHEMA,
|
|
138
|
+
handler: (args) => {
|
|
139
|
+
const parsed = FindArgs.safeParse(args);
|
|
140
|
+
if (!parsed.success) {
|
|
141
|
+
return { isError: true, content: [{ type: 'text', text: parsed.error.issues.map(({ message }) => message).join(' ') }] };
|
|
142
|
+
}
|
|
143
|
+
const { need, needs, response_format: format = 'concise' } = parsed.data;
|
|
144
|
+
const current = (finder ??= new findServices_1.ServiceFinder(catalog()));
|
|
145
|
+
const results = (needs ?? [need]).map((text) => formatResult(current.find(text), format));
|
|
146
|
+
const structuredContent = { results };
|
|
147
|
+
return { structuredContent, content: [{ type: 'text', text: JSON.stringify(structuredContent, null, 2) }] };
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=registerFindServicesTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerFindServicesTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerFindServicesTool.ts"],"names":[],"mappings":";;;AAiHA,wDAgDC;AAjKD,6BAAwB;AAExB,+DAAuF;AACvF,mCAAmE;AAEnE,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,QAAQ,GAAG,OAAC;KACf,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACzC,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;IACzE,eAAe,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC5D,CAAC;KACD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,CAAC;AAIpH,MAAM,gBAAgB,GAAG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,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;gBACpG,MAAM,iBAAiB,GAAG,EAAE,OAAO,EAAE,CAAC;gBACtC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9G,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/src/tools/types.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface ToolDefinition {
|
|
|
25
25
|
description: string;
|
|
26
26
|
inputSchema: JsonSchemaObject;
|
|
27
27
|
annotations: typeof OFFLINE_TOOL_ANNOTATIONS;
|
|
28
|
+
/** JSON Schema for `structuredContent`. A tool that declares it must return `structuredContent` on success. */
|
|
29
|
+
outputSchema?: {
|
|
30
|
+
type: 'object';
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
};
|
|
28
33
|
/**
|
|
29
34
|
* Must be a pure lookup/computation over `args` and this tool's own read-only data (docs, SDK reference) — no
|
|
30
35
|
* network calls, filesystem writes, or other external side effects. `CallToolResult.isError` on the return value
|