@ts-pf/mcp 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/call.d.ts.map +1 -1
- package/dist/call.js +2 -5
- package/dist/call.js.map +1 -1
- package/dist/error-text.d.ts +1 -1
- package/dist/error-text.d.ts.map +1 -1
- package/dist/error-text.js +8 -6
- package/dist/error-text.js.map +1 -1
- package/package.json +8 -8
- package/skills/ts-pf-mcp/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -232,7 +232,7 @@ export const tools = bindTools(planetsMcp, { app, context: () => ({ db }) })
|
|
|
232
232
|
|
|
233
233
|
`tools.list(info)` and `tools.call(name, args, info)` work without MCP, in tests or an agent framework. `McpTools` is `{ list, call, scopesFor? }` (`scopesFor` is async). `McpCallInfo` is `{ authInfo?, requestInfo?, signal?, inputResponses?, era?, tool? }`; `tool` (`{ name, path }`) is set before `context` runs, so a project that wants tool-level tracing in interceptors copies it into its own context type.
|
|
234
234
|
|
|
235
|
-
Call pipeline options live on the executor: `bindTools(toolset, { app, context, interceptors?, onError?, maxResultChars?, search? })` or `bindTools(toolset, { client, context?, onError?, maxResultChars?, search? })` (`client` may be `(info) => client`; `context` is required when the toolkit's `$context<C>()` type has required keys). `createMcpFactory(app, …)` takes the same options except `search` (it builds no hosts), plus `name`, `version`, `instructions`, `listTtlMs` (the `tools/list` cache hint, default 0); `createMcpFactory(tools, …)` takes only those four. Unknown throws become `INTERNAL: Internal server error`. `onError(error, info)` receives every tool error (and failed host searches); without it, unknown throws and `INTERNAL` errors are logged with `console.error`, like `FetchHandler
|
|
235
|
+
Call pipeline options live on the executor: `bindTools(toolset, { app, context, interceptors?, onError?, maxResultChars?, search? })` or `bindTools(toolset, { client, context?, onError?, maxResultChars?, search? })` (`client` may be `(info) => client`; `context` is required when the toolkit's `$context<C>()` type has required keys). `createMcpFactory(app, …)` takes the same options except `search` (it builds no hosts), plus `name`, `version`, `instructions`, `listTtlMs` (the `tools/list` cache hint, default 0); `createMcpFactory(tools, …)` takes only those four. Unknown throws become `INTERNAL: Internal server error`. `onError(error, info)` receives every tool error (and failed host searches); without it, unknown throws and `INTERNAL` errors are logged with `console.error`, like `FetchHandler` (`isUnexpectedError` from `@ts-pf/protocol` is that filter, for a custom `onError`). Text results are cut at `maxResultChars` (default 25,000).
|
|
236
236
|
|
|
237
237
|
`audit(toolsets, { maxTools?, maxNameLength?, missingDescription? })` returns `AuditFinding[]` (`{ level, tool, message }`) for CI: missing descriptions (`missingDescription`, default `'error'`), unclassified tools, schema roots, more than `maxTools` (15) listed tools, and names over `maxNameLength` (60) characters or outside the MCP name charset.
|
|
238
238
|
|
package/dist/call.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAa,KAAK,UAAU,EAAe,MAAM,iBAAiB,CAAA;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAChC,CAAA;AAiED,8GAA8G;AAC9G,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAqCxB"}
|
package/dist/call.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateSchema } from '@ts-pf/contract';
|
|
2
2
|
import { PFError } from '@ts-pf/protocol';
|
|
3
|
+
import { validationError } from '@ts-pf/server';
|
|
3
4
|
import { errorText, reportError } from './error-text.js';
|
|
4
5
|
import { errorResult, successResult } from './result.js';
|
|
5
6
|
function isRecord(value) {
|
|
@@ -8,11 +9,7 @@ function isRecord(value) {
|
|
|
8
9
|
async function parse(schema, value) {
|
|
9
10
|
const result = await validateSchema(schema, value);
|
|
10
11
|
if (!result.success) {
|
|
11
|
-
throw
|
|
12
|
-
code: 'VALIDATION',
|
|
13
|
-
message: 'Validation failed',
|
|
14
|
-
data: { issues: result.issues },
|
|
15
|
-
});
|
|
12
|
+
throw validationError(result.issues);
|
|
16
13
|
}
|
|
17
14
|
return result.value;
|
|
18
15
|
}
|
package/dist/call.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAE,SAAS,EAAmB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAUxD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC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gBACf,MAAM,EAAE,IAAI,CAAC,WAAW;gBACxB,MAAM,EAAE,EAAE;gBACV,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;QACD,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAClD,CAAC;AACH,CAAC"}
|
package/dist/error-text.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type ErrorTextOptions = {
|
|
|
19
19
|
* A throwing mapper propagates, so the caller reports it as unknown.
|
|
20
20
|
*/
|
|
21
21
|
export declare function errorText(error: unknown, options: ErrorTextOptions): string;
|
|
22
|
-
/** `onError` when given; otherwise log
|
|
22
|
+
/** `onError` when given; otherwise log what `isUnexpectedError` selects, as `FetchHandler` does. */
|
|
23
23
|
export declare function reportError(error: unknown, info: McpCallInfo, onError: McpOnError | undefined): void;
|
|
24
24
|
export {};
|
|
25
25
|
//# sourceMappingURL=error-text.d.ts.map
|
package/dist/error-text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-text.d.ts","sourceRoot":"","sources":["../src/error-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,+FAA+F;AAC/F,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAA;AAEpE,yFAAyF;AACzF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,MAAM,EAAE,UAAU,GACj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AW,CACzB,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,IAAI,CAYN"}
|
package/dist/error-text.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPFError, toWireError } from '@ts-pf/protocol';
|
|
1
|
+
import { isPFError, isUnexpectedError, toWireError } from '@ts-pf/protocol';
|
|
2
2
|
/** The issues plus the expected schema, so the model can repair the call in one turn. */
|
|
3
3
|
export function invalidInputText(name, issues, schema) {
|
|
4
4
|
const list = issues
|
|
@@ -39,18 +39,20 @@ export function errorText(error, options) {
|
|
|
39
39
|
const wire = toWireError(error);
|
|
40
40
|
return `${wire.code}: ${wire.message}`;
|
|
41
41
|
}
|
|
42
|
-
/** `onError` when given; otherwise log
|
|
42
|
+
/** `onError` when given; otherwise log what `isUnexpectedError` selects, as `FetchHandler` does. */
|
|
43
43
|
export function reportError(error, info, onError) {
|
|
44
44
|
if (onError) {
|
|
45
45
|
onError(error, info);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
+
if (!isUnexpectedError(error))
|
|
49
|
+
return;
|
|
48
50
|
const where = `"${info.tool?.name ?? '?'}"`;
|
|
49
|
-
if (
|
|
50
|
-
console.error(`[ts-pf/mcp] Unhandled error in ${where}:`, error);
|
|
51
|
-
}
|
|
52
|
-
else if (error.code === 'INTERNAL') {
|
|
51
|
+
if (isPFError(error)) {
|
|
53
52
|
console.error(`[ts-pf/mcp] INTERNAL error in ${where}:`, error);
|
|
54
53
|
}
|
|
54
|
+
else {
|
|
55
|
+
console.error(`[ts-pf/mcp] Unhandled error in ${where}:`, error);
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
//# sourceMappingURL=error-text.js.map
|
package/dist/error-text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-text.js","sourceRoot":"","sources":["../src/error-text.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,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,kCAAkC,KAAK,GAAG,EAAE,KAAK,CAAC,CAAA;IAClE,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-pf/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Opt-in typed projection of a ts-pf contract into MCP tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ts-pf",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"bench:types": "node bench/gen.mjs"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@ts-pf/contract": "0.
|
|
64
|
-
"@ts-pf/docs": "0.
|
|
65
|
-
"@ts-pf/protocol": "0.
|
|
66
|
-
"@ts-pf/server": "0.
|
|
63
|
+
"@ts-pf/contract": "0.5.0",
|
|
64
|
+
"@ts-pf/docs": "0.5.0",
|
|
65
|
+
"@ts-pf/protocol": "0.5.0",
|
|
66
|
+
"@ts-pf/server": "0.5.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@modelcontextprotocol/server": ">=2.3.0 <3"
|
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@modelcontextprotocol/client": "^2.3.0",
|
|
78
78
|
"@modelcontextprotocol/server": "^2.3.0",
|
|
79
|
-
"@ts-pf/client": "0.
|
|
80
|
-
"@ts-pf/client-http": "0.
|
|
81
|
-
"@ts-pf/server-http": "0.
|
|
79
|
+
"@ts-pf/client": "0.5.0",
|
|
80
|
+
"@ts-pf/client-http": "0.5.0",
|
|
81
|
+
"@ts-pf/server-http": "0.5.0",
|
|
82
82
|
"typebox": "^1.4.6",
|
|
83
83
|
"zod": "^4.0.0"
|
|
84
84
|
}
|
|
@@ -61,7 +61,7 @@ export const factory = createMcpFactory(tools, { name: 'planets', version: '1.0.
|
|
|
61
61
|
- `.input(schema, map)` replaces the model input; it is exclusive with `.inject` (inject inside the map).
|
|
62
62
|
- `.output(map)` reshapes; `.output(schema, map)` also advertises `outputSchema`, returns `structuredContent`, and checks the result (a mismatch is `INTERNAL`). Mapper `call` is a typed client on the same executor, for joins. Literal unions in a mapper return need `as const`.
|
|
63
63
|
- `all(node, { tags: ['billing'] })` and `docs({ hidden: true })` filter in the types when the contract writes them as literals; a widened `string[]` keeps the tool in the type (runtime `$coverage` still checks).
|
|
64
|
-
- `.errors({ CODE: ({ data }) => 'next step' })` for declared codes only. `VALIDATION` returns the issues plus the model-facing schema. Unknown throws are `INTERNAL: Internal server error` (via `toWireError`). `onError(error, info)` receives every tool error; without it, unknown throws and `INTERNAL` errors are logged with `console.error`.
|
|
64
|
+
- `.errors({ CODE: ({ data }) => 'next step' })` for declared codes only. `VALIDATION` returns the issues plus the model-facing schema. Unknown throws are `INTERNAL: Internal server error` (via `toWireError`). `onError(error, info)` receives every tool error; without it, unknown throws and `INTERNAL` errors are logged with `console.error`. Keep that filter in your own `onError` with `isUnexpectedError` from `@ts-pf/protocol`.
|
|
65
65
|
- More than about 15 tools in a group: `tk.$host({ description, tools: all(tk.admin) })`. `split: 'effect'` (default) gives `get_admin_query_capabilities` / `call_admin_query_capability` (read) and `get_admin_operations_capabilities` / `call_admin_operations_capability` (write + destructive); `split: false` gives `get_admin_capabilities` / `call_admin_capability`. Pin hot tools flat beside the host. Whole-server discovery is one host over `all(tk)`. By default, discovery `query` keeps only BM25 matches (name, description, `docs({ tags })`, `mcp({ aliases })`, category); add aliases for words callers use.
|
|
66
66
|
- Discovery by meaning: `bindTools(toolset, { …, search: hybridSearch({ embed }) })` (or `denseSearch`; `bm25Search()` is the default). `embed(texts, { kind: 'query' | 'document', signal })` returns one vector per text; it can run in-process (transformers.js `feature-extraction` with `pooling: 'mean', normalize: true`), with no vector database. Tool vectors are embedded on the first query and cached. Hybrid falls back to BM25 when `embed` fails (reported to `onError`); dense-only returns an error result.
|
|
67
67
|
- `tk.$coverage({ toolsets, exclude })` is a compile error (and a runtime throw) naming every procedure no toolset exposes and no `exclude` names. Hosts count; `$tool` composites do not; `docs({ hidden: true })` counts as decided at runtime (and in types when written literally).
|