@godspeedai/cognate-mcp 0.1.1 → 0.2.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 +94 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,98 @@
|
|
|
1
1
|
# @godspeedai/cognate-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Expose your Cognate application's capabilities as tools for AI assistants, over the Model
|
|
4
|
+
Context Protocol (MCP). Each capability becomes an MCP tool whose calls run through the
|
|
5
|
+
runtime's normal authorization path, so an assistant can do exactly what its authenticated
|
|
6
|
+
caller is allowed to do — and nothing more.
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
**When to use this package:** you run a Cognate runtime and want MCP clients (IDEs, agent
|
|
9
|
+
hosts, custom assistants) to invoke its capabilities safely. Authorization is per connection:
|
|
10
|
+
every tool call is invoked as the caller you bind to the server.
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
bun add @godspeedai/cognate-mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requires [Bun](https://bun.sh) >= 1.4.0. Built on the external
|
|
19
|
+
[`@modelcontextprotocol/sdk`](https://www.npmjs.com/package/@modelcontextprotocol/sdk)
|
|
20
|
+
(pinned at `1.30.1`, installed automatically), which speaks the Model Context Protocol.
|
|
21
|
+
A [`@godspeedai/cognate-runtime-bun`](https://www.npmjs.com/package/@godspeedai/cognate-runtime-bun)
|
|
22
|
+
runtime provides the capabilities being exposed. The SDK ships Bun-native TypeScript source,
|
|
23
|
+
so add `@types/bun` and `@types/node` as dev dependencies when typechecking your project.
|
|
24
|
+
|
|
25
|
+
## Quick start
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
29
|
+
import { createRuntime } from "@godspeedai/cognate-runtime-bun";
|
|
30
|
+
import { createMcpServer } from "@godspeedai/cognate-mcp";
|
|
31
|
+
|
|
32
|
+
const runtime = await createRuntime({
|
|
33
|
+
store: "./app.sqlite",
|
|
34
|
+
// ... agents, components (the capability implementations), policy
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const server = createMcpServer({
|
|
38
|
+
service: runtime.service,
|
|
39
|
+
// Every tool call on this connection is authorized as this caller:
|
|
40
|
+
caller: { actor: { id: "alice", kind: "agent" }, tenant: "tenant-a" },
|
|
41
|
+
tools: [
|
|
42
|
+
{
|
|
43
|
+
capability: "billing.quote", // the runtime capability to expose
|
|
44
|
+
description: "Quote a refund total",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: { amount: { type: "number" } },
|
|
48
|
+
required: ["amount"],
|
|
49
|
+
},
|
|
50
|
+
// name: "billing_quote" is the default: the capability id with dots replaced
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Connect to any MCP transport — stdio as here, in-memory, or your own.
|
|
56
|
+
await server.connect(new StdioServerTransport());
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
An MCP client listing tools sees one tool per binding with its JSON Schema; calling it
|
|
60
|
+
invokes the capability through `RuntimeService.invoke` as the bound caller, so kernel policy,
|
|
61
|
+
tenancy, and audit apply unchanged. A denied or failed invocation returns an MCP tool error
|
|
62
|
+
(`isError: true`) carrying the service error code and message — never a partial result.
|
|
63
|
+
|
|
64
|
+
## Behavior details
|
|
65
|
+
|
|
66
|
+
- **Tool names** default to the capability id with `.` → `_` (`billing.quote` becomes
|
|
67
|
+
`billing_quote`); override with the binding's `name`.
|
|
68
|
+
- **Input schemas** are translated from JSON Schema to the validator form the MCP SDK
|
|
69
|
+
requires: `string`, `number`, `integer`, `boolean`, `array`, and nested `object` are
|
|
70
|
+
mapped; anything unrecognized falls back to a permissive validator rather than rejecting
|
|
71
|
+
the binding.
|
|
72
|
+
- **Results** are returned as a JSON string in a single text content block.
|
|
73
|
+
- The returned object is the standard MCP SDK server, so everything the SDK documents about
|
|
74
|
+
transports and clients applies.
|
|
75
|
+
|
|
76
|
+
## Limitations
|
|
77
|
+
|
|
78
|
+
- One caller per server: create one `createMcpServer` per authenticated caller (per MCP
|
|
79
|
+
connection), not one shared across users.
|
|
80
|
+
- Only JSON-Schema subsets that translate cleanly are validated strictly; exotic schema
|
|
81
|
+
keywords are treated as permissive.
|
|
82
|
+
- The adapter exposes capabilities; it does not create them. Define components and policy in
|
|
83
|
+
the runtime first.
|
|
84
|
+
|
|
85
|
+
## Related packages
|
|
86
|
+
|
|
87
|
+
- [`@godspeedai/cognate-runtime-bun`](https://www.npmjs.com/package/@godspeedai/cognate-runtime-bun) —
|
|
88
|
+
the reference runtime whose `RuntimeService` this adapter exposes.
|
|
89
|
+
- [`@godspeedai/cognate-runtime-api`](https://www.npmjs.com/package/@godspeedai/cognate-runtime-api) —
|
|
90
|
+
the `RuntimeService`, `Caller`, and `ServiceError` types used here.
|
|
91
|
+
- [`@godspeedai/cognate`](https://www.npmjs.com/package/@godspeedai/cognate) — the SDK umbrella;
|
|
92
|
+
the easiest way to get a runtime to expose.
|
|
93
|
+
- [`@godspeedai/cognate-cli`](https://www.npmjs.com/package/@godspeedai/cognate-cli) — the
|
|
94
|
+
`cognate` command-line tooling for running and inspecting apps.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@godspeedai/cognate-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP adapter: exposes runtime capabilities as MCP tools through the runtime's authorization path.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
".": "./src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@godspeedai/cognate-events": "^0.
|
|
26
|
-
"@godspeedai/cognate-runtime-api": "^0.
|
|
25
|
+
"@godspeedai/cognate-events": "^0.2.0",
|
|
26
|
+
"@godspeedai/cognate-runtime-api": "^0.2.0",
|
|
27
27
|
"@modelcontextprotocol/sdk": "1.30.1",
|
|
28
28
|
"zod": "3.25.76"
|
|
29
29
|
},
|