@jini-ai/mcp 0.1.2 → 0.3.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 +124 -0
- package/dist/bin/serve.d.ts +25 -0
- package/dist/bin/serve.d.ts.map +1 -1
- package/dist/bin/serve.js +51 -5
- package/dist/bin/serve.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/resources/active-resource.d.ts.map +1 -1
- package/dist/server/resources/active-resource.js +3 -2
- package/dist/server/resources/active-resource.js.map +1 -1
- package/dist/server/tool-protocol.d.ts +48 -9
- package/dist/server/tool-protocol.d.ts.map +1 -1
- package/dist/server/tool-protocol.js +142 -10
- package/dist/server/tool-protocol.js.map +1 -1
- package/dist/server/tool-server.d.ts +6 -0
- package/dist/server/tool-server.d.ts.map +1 -1
- package/dist/server/tool-server.js +1 -0
- package/dist/server/tool-server.js.map +1 -1
- package/dist/server/tools/component-catalog-tools.d.ts +8 -0
- package/dist/server/tools/component-catalog-tools.d.ts.map +1 -0
- package/dist/server/tools/component-catalog-tools.js +71 -0
- package/dist/server/tools/component-catalog-tools.js.map +1 -0
- package/dist/server/tools/delegated-tool.d.ts +72 -0
- package/dist/server/tools/delegated-tool.d.ts.map +1 -1
- package/dist/server/tools/delegated-tool.js +148 -14
- package/dist/server/tools/delegated-tool.js.map +1 -1
- package/dist/server/tools/run-tools.d.ts.map +1 -1
- package/dist/server/tools/run-tools.js +8 -8
- package/dist/server/tools/run-tools.js.map +1 -1
- package/dist/server/tools/tool-catalog-tools.d.ts.map +1 -1
- package/dist/server/tools/tool-catalog-tools.js +43 -9
- package/dist/server/tools/tool-catalog-tools.js.map +1 -1
- package/package.json +10 -5
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# `@jini-ai/mcp`
|
|
2
|
+
|
|
3
|
+
Everything a Jini host needs on both sides of the Model Context Protocol. On the **server** side:
|
|
4
|
+
a generic mechanism for hosting a bounded set of MCP tools and read-only resources over stdio, plus
|
|
5
|
+
the kernel run tools (`start_run`, `get_run`, `cancel_run`, `list_agents`) already defined against
|
|
6
|
+
it, and a bootable `jini-mcp` binary an MCP client can spawn directly. On the **client/config** side:
|
|
7
|
+
a validated `mcp.json` schema with sanitizing read/write, an OAuth 2.1 + PKCE flow with a token
|
|
8
|
+
store, and installation planning that registers an MCP server into external coding agents. Nothing
|
|
9
|
+
here assumes a product layout — a caller injects the daemon URL, the tool list, and the fetch
|
|
10
|
+
implementation.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @jini-ai/mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
No peer dependencies. `@modelcontextprotocol/sdk`, `undici`, `@jini-ai/cli`, and `@jini-ai/platform`
|
|
19
|
+
are regular dependencies, installed automatically. Nothing here needs a native compile.
|
|
20
|
+
|
|
21
|
+
## What you get
|
|
22
|
+
|
|
23
|
+
**Hosting an MCP server** — `createMcpToolServer(options)` returns a handle whose `run()` serves your
|
|
24
|
+
`McpToolDef[]` (and optional `McpResourceDef[]`) over this process's stdin/stdout. Duplicate tool
|
|
25
|
+
names or resource URIs throw at construction time. Supporting pieces: `buildToolIndex`,
|
|
26
|
+
`handleToolCall`, `toolsToList`, `buildResourceIndex`, `handleResourceRead`, `resourcesToList`,
|
|
27
|
+
`okResult`/`errorResult`, `requireString`, `createMcpIdleExitController`, and the
|
|
28
|
+
`McpServerLike`/`McpTransportLike`/`createServer`/`createTransport` seams for tests.
|
|
29
|
+
|
|
30
|
+
**Kernel tool and resource definitions** — `RUN_TOOLS` plus its members `startRunTool`, `getRunTool`,
|
|
31
|
+
`cancelRunTool`, `listAgentsTool`, `getActiveContextTool`; `KERNEL_RESOURCES` and
|
|
32
|
+
`activeContextResource`; and `createExecuteDelegatedToolTool(options)` for the MCP-callback delegated
|
|
33
|
+
tool-execution path. Daemon HTTP access for those definitions goes through `getDaemonJson` /
|
|
34
|
+
`postDaemonJson`, which raise `DaemonResponseTooLargeError` rather than buffering an unbounded body.
|
|
35
|
+
|
|
36
|
+
**The `jini-mcp` binary** — `package.json` declares `"bin": { "jini-mcp": "./dist/bin/serve.js" }`.
|
|
37
|
+
One process serves exactly one run for its lifetime: the spawning daemon injects the run id into the
|
|
38
|
+
child's environment, which is what lets `execute_delegated_tool` close over a fixed `runId` instead of
|
|
39
|
+
trusting a model-supplied one. The daemon URL comes from an environment variable via `@jini-ai/cli`'s
|
|
40
|
+
`resolveDaemonUrl`, with no baked-in default. It is deliberately not re-exported from the barrel, so
|
|
41
|
+
`import '@jini-ai/mcp'` can never start behaving like a spawned server.
|
|
42
|
+
|
|
43
|
+
**Server configuration** — `McpServerConfig` / `McpConfig` / `McpTransport` / `McpAuthMode` with
|
|
44
|
+
`readMcpConfig`, `writeMcpConfig`, `sanitizeMcpServer`, `sanitizeMcpConfig`,
|
|
45
|
+
`inferMcpAuthModeForUrl`, and `isManagedProjectCwd`. Per-agent config emitters:
|
|
46
|
+
`buildClaudeMcpJson`, `buildAcpMcpServers`, `buildOpenCodeMcpConfigContent`.
|
|
47
|
+
|
|
48
|
+
**OAuth 2.1 / PKCE** — `generateCodeVerifier`, `deriveCodeChallenge`, `generateState`,
|
|
49
|
+
`discoverProtectedResource`, `discoverAuthServer`, `registerClient`, `getOrRegisterClient`,
|
|
50
|
+
`buildAuthorizeUrl`, `exchangeCodeForToken`, `refreshAccessToken`, `PendingAuthCache`, and the
|
|
51
|
+
one-call `beginAuth`.
|
|
52
|
+
|
|
53
|
+
**Token store** — `readTokensFile`, `sanitizeTokensFile`, `getToken`, `setToken`, `clearToken`,
|
|
54
|
+
`readAllTokens`, `isTokenExpired`.
|
|
55
|
+
|
|
56
|
+
**Installing into external agents** — `AGENT_SLUGS` / `isAgentSlug`, `planAgentInstall(context)`
|
|
57
|
+
returning a discriminated `InstallPlan` (`CliInstallPlan` | `JsonInstallPlan` | `ManualInstallPlan`),
|
|
58
|
+
and `applyJsonInstall` / `removeJsonInstall` to execute the JSON-file variant. Plus
|
|
59
|
+
`buildMcpInstallPayload` for the install-info payload a UI renders.
|
|
60
|
+
|
|
61
|
+
**Client-side runtime helpers** — `extractRelativeRefs`, `isTextualMime`.
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import {
|
|
67
|
+
createMcpToolServer,
|
|
68
|
+
RUN_TOOLS,
|
|
69
|
+
KERNEL_RESOURCES,
|
|
70
|
+
okResult,
|
|
71
|
+
requireString,
|
|
72
|
+
type McpToolDef,
|
|
73
|
+
} from '@jini-ai/mcp';
|
|
74
|
+
|
|
75
|
+
const greetTool: McpToolDef = {
|
|
76
|
+
name: 'greet',
|
|
77
|
+
description: 'Say hello to someone.',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: { name: { type: 'string' } },
|
|
81
|
+
required: ['name'],
|
|
82
|
+
},
|
|
83
|
+
handler: async (args) => {
|
|
84
|
+
const who = args.name;
|
|
85
|
+
requireString(who, 'name'); // asserts, throws a caller-facing error otherwise
|
|
86
|
+
return okResult(`hello ${who}`);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const server = createMcpToolServer({
|
|
91
|
+
name: 'example-mcp',
|
|
92
|
+
version: '1.0.0',
|
|
93
|
+
tools: [...RUN_TOOLS, greetTool],
|
|
94
|
+
resources: KERNEL_RESOURCES,
|
|
95
|
+
resolveBaseUrl: () => process.env.EXAMPLE_DAEMON_URL ?? 'http://127.0.0.1:4173',
|
|
96
|
+
instructions: 'Use start_run to launch work; poll get_run for status.',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await server.run(); // serves over this process's stdio until idle-exit
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Read `McpToolDef` in `src/server/` before writing your own tool — the exact `handler` and
|
|
103
|
+
`inputSchema` field shapes are what the index and the SDK bridge consume.
|
|
104
|
+
|
|
105
|
+
## What's swappable
|
|
106
|
+
|
|
107
|
+
`createMcpToolServer` is injection-first: `resolveBaseUrl`, `fetchImpl`, `stdin`, `stdout`,
|
|
108
|
+
`createServer`, and `createTransport` are all parameters, which is what makes a full server testable
|
|
109
|
+
without spawning a process or opening a socket. The tool and resource lists are yours — `RUN_TOOLS`
|
|
110
|
+
and `KERNEL_RESOURCES` are convenience defaults, not a fixed set. `createExecuteDelegatedToolTool`
|
|
111
|
+
takes its run scoping from the caller. Fixed and not replaceable: the MCP wire framing itself (that
|
|
112
|
+
is `@modelcontextprotocol/sdk`'s job), the config sanitizers' validation rules, and the OAuth flow's
|
|
113
|
+
step ordering.
|
|
114
|
+
|
|
115
|
+
## Runtime
|
|
116
|
+
|
|
117
|
+
`jini.runtime: "node"` — stdio streams, `node:fs` for the config and token stores, `node:crypto` for
|
|
118
|
+
PKCE.
|
|
119
|
+
ESM only — ships `"type": "module"` with no CommonJS `require` build.
|
|
120
|
+
|
|
121
|
+
## Provenance
|
|
122
|
+
|
|
123
|
+
See [source-map.md](./source-map.md) for per-file provenance and scope decisions. Apache-2.0,
|
|
124
|
+
inherited from Open Design — see the repo `NOTICE`.
|
package/dist/bin/serve.d.ts
CHANGED
|
@@ -43,6 +43,31 @@ import { createMcpToolServer as createMcpToolServerDefault } from '../server/too
|
|
|
43
43
|
export declare const RUN_ID_ENV_VAR = "JINI_RUN_ID";
|
|
44
44
|
/** Checked (only) when resolving the daemon HTTP base URL — see `resolveDaemonUrl`'s own docs; matches `@jini-ai/cli/main.ts`'s identically-named constant. */
|
|
45
45
|
export declare const DAEMON_URL_ENV_VAR = "JINI_DAEMON_URL";
|
|
46
|
+
/**
|
|
47
|
+
* Bearer credential for this process's daemon callbacks, set by the spawning daemon when it issued
|
|
48
|
+
* one (see `@jini-ai/daemon`'s `McpJsonInjectionOptions.credential`).
|
|
49
|
+
*
|
|
50
|
+
* **Optional, unlike {@link RUN_ID_ENV_VAR}.** A daemon whose `/api` surface trusts loopback issues
|
|
51
|
+
* no credential, and this process must keep working against one exactly as before — so an unset
|
|
52
|
+
* value means "send no `Authorization` header", never a startup failure. When a daemon *does*
|
|
53
|
+
* require a credential and none was delivered, that daemon's own gate answers 401; refusing to boot
|
|
54
|
+
* here instead would be guessing at a policy this process cannot observe.
|
|
55
|
+
*/
|
|
56
|
+
export declare const DAEMON_TOKEN_ENV_VAR = "JINI_DAEMON_TOKEN";
|
|
57
|
+
/**
|
|
58
|
+
* Overrides the delegated-tool request deadline (see `DEFAULT_DELEGATED_TOOL_TIMEOUT_MS`).
|
|
59
|
+
*
|
|
60
|
+
* **Optional.** This process is spawned as a subprocess by the daemon, so env is the only channel
|
|
61
|
+
* a host has to reach `CreateExecuteDelegatedToolToolOptions.delegatedToolTimeoutMs`; without this
|
|
62
|
+
* var that option would be unreachable in the real deployment path and the default would be the
|
|
63
|
+
* only value the system could ever run with.
|
|
64
|
+
*
|
|
65
|
+
* A host sets it to its own exchange total-lifetime ceiling plus headroom. An unset, non-numeric,
|
|
66
|
+
* or non-positive value means "use the default" rather than a startup failure — same posture as
|
|
67
|
+
* {@link DAEMON_TOKEN_ENV_VAR}, and for the same reason: this process cannot observe the host
|
|
68
|
+
* policy that would make a given number correct, so it must not refuse to boot over one.
|
|
69
|
+
*/
|
|
70
|
+
export declare const DELEGATED_TOOL_TIMEOUT_ENV_VAR = "JINI_DELEGATED_TOOL_TIMEOUT_MS";
|
|
46
71
|
export interface ServeDeps {
|
|
47
72
|
/** @default process.env */
|
|
48
73
|
readonly env?: NodeJS.ProcessEnv;
|
package/dist/bin/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/bin/serve.ts"],"names":[],"mappings":";AACA;;;;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AmB,CAAC,EAAE,OAAO,0BAA0B,CAAC;IACjE,wGAAwG;IACxG,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC;IAC1C,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAMD;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,IAAI,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAqE/D"}
|
package/dist/bin/serve.js
CHANGED
|
@@ -4,12 +4,38 @@ import { resolveDaemonUrl as resolveDaemonUrlDefault } from '@jini-ai/cli';
|
|
|
4
4
|
import { createMcpToolServer as createMcpToolServerDefault } from '../server/tool-server.js';
|
|
5
5
|
import { RUN_TOOLS } from '../server/tools/run-tools.js';
|
|
6
6
|
import { TOOL_CATALOG_TOOLS } from '../server/tools/tool-catalog-tools.js';
|
|
7
|
-
import {
|
|
7
|
+
import { COMPONENT_CATALOG_TOOLS } from '../server/tools/component-catalog-tools.js';
|
|
8
|
+
import { createExecuteDelegatedToolTool, createExecuteReadonlyDelegatedToolTool } from '../server/tools/delegated-tool.js';
|
|
8
9
|
import { KERNEL_RESOURCES } from '../server/resources/active-resource.js';
|
|
9
10
|
/** The one run this process is scoped to for its entire lifetime. Set by the spawning daemon, never by the MCP client. */
|
|
10
11
|
export const RUN_ID_ENV_VAR = 'JINI_RUN_ID';
|
|
11
12
|
/** Checked (only) when resolving the daemon HTTP base URL — see `resolveDaemonUrl`'s own docs; matches `@jini-ai/cli/main.ts`'s identically-named constant. */
|
|
12
13
|
export const DAEMON_URL_ENV_VAR = 'JINI_DAEMON_URL';
|
|
14
|
+
/**
|
|
15
|
+
* Bearer credential for this process's daemon callbacks, set by the spawning daemon when it issued
|
|
16
|
+
* one (see `@jini-ai/daemon`'s `McpJsonInjectionOptions.credential`).
|
|
17
|
+
*
|
|
18
|
+
* **Optional, unlike {@link RUN_ID_ENV_VAR}.** A daemon whose `/api` surface trusts loopback issues
|
|
19
|
+
* no credential, and this process must keep working against one exactly as before — so an unset
|
|
20
|
+
* value means "send no `Authorization` header", never a startup failure. When a daemon *does*
|
|
21
|
+
* require a credential and none was delivered, that daemon's own gate answers 401; refusing to boot
|
|
22
|
+
* here instead would be guessing at a policy this process cannot observe.
|
|
23
|
+
*/
|
|
24
|
+
export const DAEMON_TOKEN_ENV_VAR = 'JINI_DAEMON_TOKEN';
|
|
25
|
+
/**
|
|
26
|
+
* Overrides the delegated-tool request deadline (see `DEFAULT_DELEGATED_TOOL_TIMEOUT_MS`).
|
|
27
|
+
*
|
|
28
|
+
* **Optional.** This process is spawned as a subprocess by the daemon, so env is the only channel
|
|
29
|
+
* a host has to reach `CreateExecuteDelegatedToolToolOptions.delegatedToolTimeoutMs`; without this
|
|
30
|
+
* var that option would be unreachable in the real deployment path and the default would be the
|
|
31
|
+
* only value the system could ever run with.
|
|
32
|
+
*
|
|
33
|
+
* A host sets it to its own exchange total-lifetime ceiling plus headroom. An unset, non-numeric,
|
|
34
|
+
* or non-positive value means "use the default" rather than a startup failure — same posture as
|
|
35
|
+
* {@link DAEMON_TOKEN_ENV_VAR}, and for the same reason: this process cannot observe the host
|
|
36
|
+
* policy that would make a given number correct, so it must not refuse to boot over one.
|
|
37
|
+
*/
|
|
38
|
+
export const DELEGATED_TOOL_TIMEOUT_ENV_VAR = 'JINI_DELEGATED_TOOL_TIMEOUT_MS';
|
|
13
39
|
const SERVER_NAME = 'jini-mcp';
|
|
14
40
|
const SERVER_VERSION = '0.0.0';
|
|
15
41
|
const INSTRUCTIONS = 'Tools proxying this host\'s Jini daemon over loopback HTTP, scoped to the run that spawned this MCP server process. ' +
|
|
@@ -41,14 +67,33 @@ export async function serve(deps = {}) {
|
|
|
41
67
|
const options = { flagUrl: null, env, envVarName: DAEMON_URL_ENV_VAR, warn: writeErr };
|
|
42
68
|
return resolveDaemonUrlFn(options);
|
|
43
69
|
};
|
|
70
|
+
// Shared by both gateways so their run scope, correlation-id source, and deadline cannot diverge
|
|
71
|
+
// — the only difference between the two defs is the read-only constraint each declares.
|
|
72
|
+
const delegatedGatewayOptions = {
|
|
73
|
+
runId,
|
|
74
|
+
...(deps.generateToolUseId !== undefined ? { generateToolUseId: deps.generateToolUseId } : {}),
|
|
75
|
+
// Parsed, not validated: `createExecuteDelegatedToolTool` already rejects a non-finite or
|
|
76
|
+
// non-positive value back to the default, so `NaN` from a malformed env var lands there too.
|
|
77
|
+
...(env[DELEGATED_TOOL_TIMEOUT_ENV_VAR] !== undefined
|
|
78
|
+
? { delegatedToolTimeoutMs: Number(env[DELEGATED_TOOL_TIMEOUT_ENV_VAR]) }
|
|
79
|
+
: {}),
|
|
80
|
+
};
|
|
44
81
|
const tools = [
|
|
45
82
|
...RUN_TOOLS,
|
|
46
83
|
...TOOL_CATALOG_TOOLS,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
84
|
+
...COMPONENT_CATALOG_TOOLS,
|
|
85
|
+
createExecuteDelegatedToolTool(delegatedGatewayOptions),
|
|
86
|
+
// Hosted ALONGSIDE the unconstrained gateway, never instead of it. A client that gates on
|
|
87
|
+
// `readOnlyHint: true` can now reach the read half of the catalog at all; every other client
|
|
88
|
+
// sees both and picks by what its call actually does.
|
|
89
|
+
createExecuteReadonlyDelegatedToolTool(delegatedGatewayOptions),
|
|
51
90
|
];
|
|
91
|
+
// Absent credential => no `authHeaders` at all => byte-identical request headers to before this
|
|
92
|
+
// env var existed. See DAEMON_TOKEN_ENV_VAR's doc for why an unset value is not a startup failure.
|
|
93
|
+
const credential = env[DAEMON_TOKEN_ENV_VAR];
|
|
94
|
+
const authHeaders = typeof credential === 'string' && credential.length > 0
|
|
95
|
+
? { Authorization: `Bearer ${credential}` }
|
|
96
|
+
: undefined;
|
|
52
97
|
const serverOptions = {
|
|
53
98
|
name: SERVER_NAME,
|
|
54
99
|
version: SERVER_VERSION,
|
|
@@ -56,6 +101,7 @@ export async function serve(deps = {}) {
|
|
|
56
101
|
resources: KERNEL_RESOURCES,
|
|
57
102
|
resolveBaseUrl,
|
|
58
103
|
instructions: INSTRUCTIONS,
|
|
104
|
+
...(authHeaders !== undefined ? { authHeaders } : {}),
|
|
59
105
|
...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),
|
|
60
106
|
...(deps.stdin !== undefined ? { stdin: deps.stdin } : {}),
|
|
61
107
|
...(deps.stdout !== undefined ? { stdout: deps.stdout } : {}),
|
package/dist/bin/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/bin/serve.ts"],"names":[],"mappings":";AAuCA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAgC,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAA6B,MAAM,0BAA0B,CAAC;AAExH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/bin/serve.ts"],"names":[],"mappings":";AAuCA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAgC,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAA6B,MAAM,0BAA0B,CAAC;AAExH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,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AAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzG,IAAI,YAAY,EAAE,CAAC;IACjB,MAAM,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,11 +17,13 @@ export type { StoredMcpToken, McpTokensFile } from './core/index.js';
|
|
|
17
17
|
export { buildMcpInstallPayload } from './core/index.js';
|
|
18
18
|
export type { BuildMcpInstallPayloadInputs, McpInstallPayload } from './core/index.js';
|
|
19
19
|
export { createMcpIdleExitController, extractRelativeRefs, isTextualMime, } from './client/index.js';
|
|
20
|
-
export { cancelRunTool, createMcpToolServer, errorResult, getActiveContextTool, getDaemonJson, getRunTool, listAgentsTool, okResult, postDaemonJson, requireString, RUN_TOOLS, startRunTool, toolsToList, buildToolIndex, handleToolCall, DaemonResponseTooLargeError, } from './server/index.js';
|
|
20
|
+
export { cancelRunTool, createMcpToolServer, daemonCallOptions, errorResult, getActiveContextTool, getDaemonJson, getRunTool, listAgentsTool, okResult, postDaemonJson, requireString, RUN_TOOLS, startRunTool, toolsToList, buildToolIndex, handleToolCall, DaemonResponseTooLargeError, } from './server/index.js';
|
|
21
21
|
export type { DaemonRequestOptions, McpServerLike, McpToolContext, McpToolDef, McpToolServerHandle, McpToolServerOptions, McpTransportLike, } from './server/index.js';
|
|
22
22
|
export { activeContextResource, buildResourceIndex, handleResourceRead, KERNEL_RESOURCES, resourcesToList, } from './server/index.js';
|
|
23
23
|
export type { McpResourceDef, McpResourceReadResult } from './server/index.js';
|
|
24
|
-
export {
|
|
24
|
+
export { searchToolsTool, describeToolTool, TOOL_CATALOG_TOOLS } from './server/index.js';
|
|
25
|
+
export { searchComponentsTool, describeComponentTool, COMPONENT_CATALOG_TOOLS } from './server/index.js';
|
|
26
|
+
export { createExecuteDelegatedToolTool, createExecuteReadonlyDelegatedToolTool, DEFAULT_DELEGATED_TOOL_TIMEOUT_MS, } from './server/index.js';
|
|
25
27
|
export type { CreateExecuteDelegatedToolToolOptions } from './server/index.js';
|
|
26
28
|
export { AGENT_SLUGS, isAgentSlug, planAgentInstall, applyJsonInstall, removeJsonInstall, } from './agent-install/index.js';
|
|
27
29
|
export type { AgentSlug, McpLaunchSpec, PlanContext, CliInstallPlan, JsonInstallPlan, ManualInstallPlan, InstallPlan, } from './agent-install/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGvF,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,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,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG1F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAGzG,OAAO,EACL,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,GAClC,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,qCAAqC,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,WAAW,GACZ,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,11 +19,15 @@ export { buildMcpInstallPayload } from './core/index.js';
|
|
|
19
19
|
// ── client: product-neutral stdio-server runtime primitives ─────────────────
|
|
20
20
|
export { createMcpIdleExitController, extractRelativeRefs, isTextualMime, } from './client/index.js';
|
|
21
21
|
// ── server: the generic MCP tool-hosting mechanism + kernel-run tool defs ───
|
|
22
|
-
export { cancelRunTool, createMcpToolServer, errorResult, getActiveContextTool, getDaemonJson, getRunTool, listAgentsTool, okResult, postDaemonJson, requireString, RUN_TOOLS, startRunTool, toolsToList, buildToolIndex, handleToolCall, DaemonResponseTooLargeError, } from './server/index.js';
|
|
22
|
+
export { cancelRunTool, createMcpToolServer, daemonCallOptions, errorResult, getActiveContextTool, getDaemonJson, getRunTool, listAgentsTool, okResult, postDaemonJson, requireString, RUN_TOOLS, startRunTool, toolsToList, buildToolIndex, handleToolCall, DaemonResponseTooLargeError, } from './server/index.js';
|
|
23
23
|
// ── server: the generic MCP resource surface + kernel resource defs ────────
|
|
24
24
|
export { activeContextResource, buildResourceIndex, handleResourceRead, KERNEL_RESOURCES, resourcesToList, } from './server/index.js';
|
|
25
|
+
// ── server: the tool-catalog discovery defs (search_tools / describe_tool) ──
|
|
26
|
+
export { searchToolsTool, describeToolTool, TOOL_CATALOG_TOOLS } from './server/index.js';
|
|
27
|
+
// ── server: the component-catalog discovery defs (search_components / describe_component) ──
|
|
28
|
+
export { searchComponentsTool, describeComponentTool, COMPONENT_CATALOG_TOOLS } from './server/index.js';
|
|
25
29
|
// ── server: gap 3's MCP-callback delegated-tool-execution def ──────────────
|
|
26
|
-
export { createExecuteDelegatedToolTool } from './server/index.js';
|
|
30
|
+
export { createExecuteDelegatedToolTool, createExecuteReadonlyDelegatedToolTool, DEFAULT_DELEGATED_TOOL_TIMEOUT_MS, } from './server/index.js';
|
|
27
31
|
// ── agent-install: register an MCP server into external agents ──────────────
|
|
28
32
|
export { AGENT_SLUGS, isAgentSlug, planAgentInstall, applyJsonInstall, removeJsonInstall, } from './agent-install/index.js';
|
|
29
33
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,+EAA+E;AAC/E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAUzB,+EAA+E;AAC/E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAczB,+EAA+E;AAC/E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,+EAA+E;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,+EAA+E;AAC/E,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,+EAA+E;AAC/E,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAW3B,8EAA8E;AAC9E,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,8EAA8E;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,+EAA+E;AAC/E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAUzB,+EAA+E;AAC/E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAczB,+EAA+E;AAC/E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,+EAA+E;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,+EAA+E;AAC/E,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,+EAA+E;AAC/E,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAW3B,8EAA8E;AAC9E,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,+EAA+E;AAC/E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1F,8FAA8F;AAC9F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEzG,8EAA8E;AAC9E,OAAO,EACL,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,GAClC,MAAM,mBAAmB,CAAC;AAG3B,+EAA+E;AAC/E,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* layer (`tool-protocol.ts`), the pure resource protocol layer
|
|
5
5
|
* (`resource-protocol.ts`), the daemon transport (`daemon-client.ts`), the
|
|
6
6
|
* `Server`/`StdioServerTransport` wiring (`tool-server.ts`), the concrete
|
|
7
|
-
* kernel-run tool defs (`tools/run-tools.ts`), the
|
|
7
|
+
* kernel-run tool defs (`tools/run-tools.ts`), the tool-catalog discovery
|
|
8
|
+
* defs (`tools/tool-catalog-tools.ts`), the component-catalog discovery
|
|
9
|
+
* defs (`tools/component-catalog-tools.ts`), the concrete kernel
|
|
8
10
|
* resource defs (`resources/active-resource.ts`), and the delegated-tool
|
|
9
11
|
* execution def (`tools/delegated-tool.ts`).
|
|
10
12
|
*/
|
|
@@ -14,5 +16,7 @@ export * from './daemon-client.js';
|
|
|
14
16
|
export * from './tool-server.js';
|
|
15
17
|
export * from './tools/run-tools.js';
|
|
16
18
|
export * from './tools/delegated-tool.js';
|
|
19
|
+
export * from './tools/tool-catalog-tools.js';
|
|
20
|
+
export * from './tools/component-catalog-tools.js';
|
|
17
21
|
export * from './resources/active-resource.js';
|
|
18
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* layer (`tool-protocol.ts`), the pure resource protocol layer
|
|
5
5
|
* (`resource-protocol.ts`), the daemon transport (`daemon-client.ts`), the
|
|
6
6
|
* `Server`/`StdioServerTransport` wiring (`tool-server.ts`), the concrete
|
|
7
|
-
* kernel-run tool defs (`tools/run-tools.ts`), the
|
|
7
|
+
* kernel-run tool defs (`tools/run-tools.ts`), the tool-catalog discovery
|
|
8
|
+
* defs (`tools/tool-catalog-tools.ts`), the component-catalog discovery
|
|
9
|
+
* defs (`tools/component-catalog-tools.ts`), the concrete kernel
|
|
8
10
|
* resource defs (`resources/active-resource.ts`), and the delegated-tool
|
|
9
11
|
* execution def (`tools/delegated-tool.ts`).
|
|
10
12
|
*/
|
|
@@ -14,5 +16,7 @@ export * from './daemon-client.js';
|
|
|
14
16
|
export * from './tool-server.js';
|
|
15
17
|
export * from './tools/run-tools.js';
|
|
16
18
|
export * from './tools/delegated-tool.js';
|
|
19
|
+
export * from './tools/tool-catalog-tools.js';
|
|
20
|
+
export * from './tools/component-catalog-tools.js';
|
|
17
21
|
export * from './resources/active-resource.js';
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-resource.d.ts","sourceRoot":"","sources":["../../../src/server/resources/active-resource.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"active-resource.d.ts","sourceRoot":"","sources":["../../../src/server/resources/active-resource.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAQ9D;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAUnC,CAAC;AAEF,4HAA4H;AAC5H,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAA4B,CAAC"}
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
* same way (both require a Skill/DesignSystem noun this kernel doesn't have).
|
|
19
19
|
*
|
|
20
20
|
* Security posture matches every other tool/resource in this package: no
|
|
21
|
-
* separate authorization mechanism here — whatever `@jini-ai/http`'s
|
|
21
|
+
* separate authorization mechanism here — whatever `@jini-ai/http-kit`'s
|
|
22
22
|
* same-origin guard / bearer-auth middleware already enforces on
|
|
23
23
|
* `GET /api/active` is the only gate a read of this resource passes
|
|
24
24
|
* through.
|
|
25
25
|
*/
|
|
26
26
|
import { getDaemonJson } from '../daemon-client.js';
|
|
27
|
+
import { daemonCallOptions } from '../tool-protocol.js';
|
|
27
28
|
/**
|
|
28
29
|
* `jini://active` -> `GET /api/active`. Returns the raw daemon payload as formatted JSON text,
|
|
29
30
|
* unchanged — unlike `getActiveContextTool`, this does not add a conversational hint when
|
|
@@ -37,7 +38,7 @@ export const activeContextResource = {
|
|
|
37
38
|
description: 'The resource (resourceRef) plus optional detail the caller last recorded as its current focus via POST /api/active — the same generic, product-neutral pointer the get_active_context tool proxies, exposed here as an attachable MCP resource instead of a tool call.',
|
|
38
39
|
mimeType: 'application/json',
|
|
39
40
|
read: async (ctx) => {
|
|
40
|
-
const data = await getDaemonJson(ctx.baseUrl, '/api/active',
|
|
41
|
+
const data = await getDaemonJson(ctx.baseUrl, '/api/active', daemonCallOptions(ctx));
|
|
41
42
|
return { text: JSON.stringify(data, null, 2) };
|
|
42
43
|
},
|
|
43
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-resource.js","sourceRoot":"","sources":["../../../src/server/resources/active-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"active-resource.js","sourceRoot":"","sources":["../../../src/server/resources/active-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACnD,GAAG,EAAE,eAAe;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,wQAAwQ;IAC1Q,QAAQ,EAAE,kBAAkB;IAC5B,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAClB,MAAM,IAAI,GAAG,MAAM,aAAa,CAAuB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3G,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IACjD,CAAC;CACF,CAAC;AAEF,4HAA4H;AAC5H,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -5,7 +5,33 @@ export interface McpToolContext {
|
|
|
5
5
|
readonly baseUrl: string;
|
|
6
6
|
/** Defaults to the global `fetch`; threaded through so a host can inject its own (e.g. for tests). */
|
|
7
7
|
readonly fetchImpl: typeof fetch;
|
|
8
|
+
/**
|
|
9
|
+
* Headers every daemon call must carry — in practice `{ Authorization: 'Bearer <token>' }` when the
|
|
10
|
+
* spawning daemon gave this process a credential (`JINI_DAEMON_TOKEN`). Empty/absent when it did
|
|
11
|
+
* not, which is the pre-existing behavior for a daemon whose `/api` surface trusts loopback.
|
|
12
|
+
*
|
|
13
|
+
* Read it via {@link daemonCallOptions} rather than by hand — see that function's doc.
|
|
14
|
+
*/
|
|
15
|
+
readonly authHeaders?: Readonly<Record<string, string>>;
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Maps a tool context onto the `DaemonRequestOptions` every daemon call needs.
|
|
19
|
+
*
|
|
20
|
+
* **Use this instead of writing `{ fetchImpl: ctx.fetchImpl }` inline.** Both fields have to travel
|
|
21
|
+
* together on every call, and the failure mode when one is forgotten is not a compile error but a
|
|
22
|
+
* silent 401 from that one tool while every other tool keeps working — the kind of bug that reaches
|
|
23
|
+
* a user as "some of these tools just don't do anything". Routing every call site through one
|
|
24
|
+
* mapping means a newly added tool is authenticated by construction.
|
|
25
|
+
*
|
|
26
|
+
* @param ctx - The context handed to a tool or resource handler.
|
|
27
|
+
* @returns Options carrying the injected `fetch` and, when present, the auth headers.
|
|
28
|
+
* @complexity O(1).
|
|
29
|
+
* @overallScore 100/100
|
|
30
|
+
*/
|
|
31
|
+
export declare function daemonCallOptions(ctx: McpToolContext): {
|
|
32
|
+
fetchImpl: typeof fetch;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
};
|
|
9
35
|
/**
|
|
10
36
|
* One MCP tool a `createMcpToolServer` caller registers. `name` must be unique within a given
|
|
11
37
|
* tool list (`buildToolIndex` throws otherwise — a caller bug, not something to silently drop).
|
|
@@ -21,7 +47,18 @@ export interface McpToolDef<Args extends Record<string, unknown> = Record<string
|
|
|
21
47
|
readonly annotations?: Tool['annotations'];
|
|
22
48
|
readonly handler: (args: Args, ctx: McpToolContext) => Promise<unknown> | unknown;
|
|
23
49
|
}
|
|
24
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Wraps a successful tool result as an MCP `CallToolResult`.
|
|
52
|
+
*
|
|
53
|
+
* A payload that is already a well-formed MCP content envelope (see {@link isMcpContentEnvelope}) is
|
|
54
|
+
* returned with its `content` array verbatim, so a typed block inside it — an `image`, today — reaches
|
|
55
|
+
* the client as a real content block rather than flattened text (see this module's own doc for the
|
|
56
|
+
* bug this closes). Every other payload keeps the original behavior: a string passes through as one
|
|
57
|
+
* text block; anything else is JSON-stringified into one.
|
|
58
|
+
*
|
|
59
|
+
* @complexity O(n) in the number of content-array entries, only when `payload` already looks like an
|
|
60
|
+
* envelope; O(1) otherwise.
|
|
61
|
+
*/
|
|
25
62
|
export declare function okResult(payload: unknown): CallToolResult;
|
|
26
63
|
/** Wraps a tool failure as an MCP `isError` result. */
|
|
27
64
|
export declare function errorResult(message: string): CallToolResult;
|
|
@@ -32,14 +69,16 @@ export declare function toolsToList(tools: readonly McpToolDef[]): Tool[];
|
|
|
32
69
|
/** Builds a name -> def lookup, throwing if two tools in `tools` share a name (a caller-configuration bug, surfaced eagerly at server-construction time rather than silently letting the second registration shadow the first). */
|
|
33
70
|
export declare function buildToolIndex(tools: readonly McpToolDef[]): Map<string, McpToolDef>;
|
|
34
71
|
/**
|
|
35
|
-
* `tools/call` dispatch: looks up `name` in `tools`,
|
|
36
|
-
* converts the outcome to a `CallToolResult` — an
|
|
37
|
-
* produce an `{isError:true}` result
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
72
|
+
* `tools/call` dispatch: looks up `name` in `tools`, validates `rawArgs` against the tool's
|
|
73
|
+
* declared `inputSchema`, runs its handler, and converts the outcome to a `CallToolResult` — an
|
|
74
|
+
* unknown tool name, a schema violation, or a thrown error all produce an `{isError:true}` result
|
|
75
|
+
* rather than rejecting, matching MCP's convention that tool failures are protocol-level results,
|
|
76
|
+
* not JSON-RPC errors. Schema validation runs before every handler unconditionally: a caller (an
|
|
77
|
+
* agent, not this repo's own code) supplies `rawArgs`, so a handler must never be trusted to check
|
|
78
|
+
* its own declared contract on the untrusted-input path. Both a validation failure's message and a
|
|
79
|
+
* thrown error's message are passed through {@link sanitizeUntrustedText} before reaching the
|
|
80
|
+
* result: either can end up echoing caller- or daemon-supplied text, and it is cheaper to sanitize
|
|
81
|
+
* unconditionally than to prove which call site needs it.
|
|
43
82
|
*/
|
|
44
83
|
export declare function handleToolCall(name: string, rawArgs: Record<string, unknown> | undefined, tools: ReadonlyMap<string, McpToolDef>, ctx: McpToolContext): Promise<CallToolResult>;
|
|
45
84
|
//# sourceMappingURL=tool-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-protocol.d.ts","sourceRoot":"","sources":["../../src/server/tool-protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-protocol.d.ts","sourceRoot":"","sources":["../../src/server/tool-protocol.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/E,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,uGAAuG;IACvG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sGAAsG;IACtG,QAAQ,CAAC,SAAS,EAAE,OAAO,KAAK,CAAC;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG;IAAE,SAAS,EAAE,OAAO,KAAK,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAKpH;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3C,QAAQ,CAAC,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