@adhd/apigen-plugin-mcp 0.1.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 +20 -0
- package/index.d.ts +2 -0
- package/index.js +31527 -0
- package/index.mjs +384894 -0
- package/lib/generate.d.ts +3 -0
- package/lib/plugin.d.ts +4 -0
- package/lib/run.d.ts +3 -0
- package/lib/stream.d.ts +47 -0
- package/lib/templates/server-http.tpl.d.ts +2 -0
- package/lib/templates/server-stdio.tpl.d.ts +2 -0
- package/package.json +15 -0
package/lib/plugin.d.ts
ADDED
package/lib/run.d.ts
ADDED
package/lib/stream.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApiStream } from '@adhd/apigen-runtime';
|
|
2
|
+
|
|
3
|
+
/** A single MCP content item (text carrier). */
|
|
4
|
+
export interface McpTextContent {
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
/** The MCP CallTool result envelope. */
|
|
9
|
+
export interface McpCallToolResult {
|
|
10
|
+
content: McpTextContent[];
|
|
11
|
+
isError?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Drain `stream` and return the accumulated MCP result envelope.
|
|
15
|
+
*
|
|
16
|
+
* Chunks are collected in order; a terminal error after the first chunk is
|
|
17
|
+
* appended as an in-band error notification (`isError: true`).
|
|
18
|
+
*
|
|
19
|
+
* Because the MCP SDK's `CallToolRequestSchema` handler is a regular
|
|
20
|
+
* `async function` (returning a single value, not a generator), we cannot
|
|
21
|
+
* truly stream chunks over the wire — the SDK serialises the whole response
|
|
22
|
+
* once returned. The projection therefore **collects all chunks** and returns
|
|
23
|
+
* them as an ordered array of `content` items, which is the idiomatic MCP
|
|
24
|
+
* "progressive results" shape. Each chunk occupies one `content` slot in
|
|
25
|
+
* order.
|
|
26
|
+
*
|
|
27
|
+
* When the wire transport supports streaming (e.g. MCP over SSE with
|
|
28
|
+
* server-initiated notifications), a future revision may use
|
|
29
|
+
* `server.notification()` per chunk. The current shape is forward-compatible:
|
|
30
|
+
* the terminal item remains last.
|
|
31
|
+
*
|
|
32
|
+
* @param stream - the `ApiStream` returned by the Layer harness for a
|
|
33
|
+
* `streaming:true` operation.
|
|
34
|
+
* @returns a Promise resolving to the MCP `CallToolResult` envelope.
|
|
35
|
+
*/
|
|
36
|
+
export declare function projectStreamMcp(stream: ApiStream<unknown>): Promise<McpCallToolResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Drain `stream` collecting partial chunks AND the terminal error in-band.
|
|
39
|
+
*
|
|
40
|
+
* Unlike `projectStreamMcp`, this variant re-drives the stream manually to
|
|
41
|
+
* accumulate chunk values even when an error-after-first-chunk occurs, giving
|
|
42
|
+
* transport adapters the full `[chunk…, errorPayload]` content array.
|
|
43
|
+
*
|
|
44
|
+
* This is the **preferred** function for MCP transports that want to expose
|
|
45
|
+
* all partial data to the client.
|
|
46
|
+
*/
|
|
47
|
+
export declare function projectStreamMcpFull(stream: ApiStream<unknown>): Promise<McpCallToolResult>;
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adhd/apigen-plugin-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@adhd/apigen-core": "^0.1.0",
|
|
7
|
+
"@adhd/apigen-runtime": "^0.1.0",
|
|
8
|
+
"@modelcontextprotocol/sdk": "1.29.0"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"module": "./index.mjs",
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
|
+
}
|