@usegraft/mcp 0.2.0 → 1.0.0-beta.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/index.d.ts +83 -2
- package/dist/index.js +1095 -169
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -50,4 +50,4 @@ Content: `list_content`, `read_content`, `write_content`, `delete_content`, `sea
|
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
MIT. [Repository](https://github.com/AndersonDesign1/graft) · [Changelog](https://github.com/AndersonDesign1/graft/blob/
|
|
53
|
+
MIT. [Repository](https://github.com/AndersonDesign1/graft) · [Changelog](https://github.com/AndersonDesign1/graft/blob/main/packages/mcp/CHANGELOG.md) · [Security policy](https://github.com/AndersonDesign1/graft/blob/main/SECURITY.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -86,7 +86,20 @@ interface GraftMcpOptions {
|
|
|
86
86
|
* hero image from the repo is the case the argument exists for.
|
|
87
87
|
*/
|
|
88
88
|
localUploadRoot?: string;
|
|
89
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Forwarded to createFunctionsHandler for run_function.
|
|
91
|
+
*
|
|
92
|
+
* Deliberately narrower than the core option, which also accepts
|
|
93
|
+
* `"unattended"`. That policy exists for a deployment with no human to ask —
|
|
94
|
+
* a scheduled job, a CI step — and an MCP mount is the opposite of that: it
|
|
95
|
+
* exists because an agent is calling it, and the agent is the party the gate
|
|
96
|
+
* is there to stop. Allowing it here would let one option turn every
|
|
97
|
+
* destructive tool an agent can reach into an ungated one.
|
|
98
|
+
*
|
|
99
|
+
* A headless deployment that genuinely wants it still has it, on
|
|
100
|
+
* `createFunctionsHandler` and through `approvalPolicy` in graft.config.ts on
|
|
101
|
+
* `graft serve`'s /api/fn routes. It just does not reach the tool surface.
|
|
102
|
+
*/
|
|
90
103
|
approvalPolicy?: "none" | "human";
|
|
91
104
|
rateLimit?: RateLimit;
|
|
92
105
|
gitSha?: string;
|
|
@@ -98,6 +111,36 @@ interface GraftMcpOptions {
|
|
|
98
111
|
* GRAFT_DEV_TOKEN; the HTTP handler forwards the caller's own header.
|
|
99
112
|
*/
|
|
100
113
|
defaultAuthorization?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Ask the connected client's human to decide a pending approval in-band,
|
|
116
|
+
* instead of failing with an id and waiting for someone to run
|
|
117
|
+
* `graft approve`.
|
|
118
|
+
*
|
|
119
|
+
* **Off unless configured, and it belongs only on a mount whose human is
|
|
120
|
+
* actually present** — a local stdio server, a desktop client. A remote or
|
|
121
|
+
* public mount must never set it: there is nobody at the other end to ask,
|
|
122
|
+
* and an elicitation nobody answers is a destructive call left hanging.
|
|
123
|
+
*
|
|
124
|
+
* The reason this needs an explicit `decider` rather than reusing the
|
|
125
|
+
* connection's identity is the invariant underneath: `decideApproval`
|
|
126
|
+
* enforces `requested_by_id <> decided_by` in the UPDATE's own WHERE, so a
|
|
127
|
+
* requester deciding its own approval is refused by Postgres, not by a guard
|
|
128
|
+
* that could be forgotten. Elicitation changes *how the human is asked*, not
|
|
129
|
+
* *who is recorded as having answered*. Name the operator sitting at the
|
|
130
|
+
* machine; if that operator is also the requester, the decision is refused
|
|
131
|
+
* exactly as it would be from the CLI.
|
|
132
|
+
*
|
|
133
|
+
* Deciding is a plain UPDATE on `approvals`, which the hardened runtime role
|
|
134
|
+
* deliberately cannot perform (see `graft harden`). On such a deployment this
|
|
135
|
+
* fails, correctly and by construction.
|
|
136
|
+
*/
|
|
137
|
+
approvalElicitation?: {
|
|
138
|
+
/** The operator a decision is attributed to. Never the requester. */
|
|
139
|
+
decider: {
|
|
140
|
+
kind: string;
|
|
141
|
+
id: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
101
144
|
/**
|
|
102
145
|
* Audit / approval stores for run_function. Defaults match createFunctionsHandler
|
|
103
146
|
* (db-backed). Pass `audit: false` in unit tests that do not hit a real DB.
|
|
@@ -117,7 +160,25 @@ interface GraftMcpOptions {
|
|
|
117
160
|
storage?: Storage | (() => Storage | Promise<Storage>);
|
|
118
161
|
}
|
|
119
162
|
|
|
163
|
+
/**
|
|
164
|
+
* What a public documentation server needs, which is much less than the full
|
|
165
|
+
* one. No `functions`, no `actor`, no asset store, no approval elicitation:
|
|
166
|
+
* omitting them from the type is what keeps them from being configured by
|
|
167
|
+
* accident on a mount that answers the internet.
|
|
168
|
+
*/
|
|
169
|
+
type DocsMcpOptions = Pick<GraftMcpOptions, "contentDir" | "collections" | "db" | "staticIndexPath" | "branchId" | "scope" | "name" | "version">;
|
|
120
170
|
declare function createGraftMcp(options: GraftMcpOptions): McpServer;
|
|
171
|
+
/**
|
|
172
|
+
* A public, read-only documentation server.
|
|
173
|
+
*
|
|
174
|
+
* A separate factory rather than a flag on `createGraftMcp`, because the
|
|
175
|
+
* safety property worth having is that the closed mount gains no new way to be
|
|
176
|
+
* opened. There is no option here that widens the surface; reaching the wider
|
|
177
|
+
* one means calling the other function.
|
|
178
|
+
*
|
|
179
|
+
* Serve it at `/mcp` on the docs domain, which is where clients look.
|
|
180
|
+
*/
|
|
181
|
+
declare function createDocsMcp(options: DocsMcpOptions): McpServer;
|
|
121
182
|
|
|
122
183
|
interface GraftMcpHandlerOptions extends GraftMcpOptions {
|
|
123
184
|
/**
|
|
@@ -143,6 +204,20 @@ interface GraftMcpHandlerOptions extends GraftMcpOptions {
|
|
|
143
204
|
}
|
|
144
205
|
type GraftMcpHandler = (request: Request) => Promise<Response>;
|
|
145
206
|
declare function createGraftMcpHandler(options: GraftMcpHandlerOptions): GraftMcpHandler;
|
|
207
|
+
/**
|
|
208
|
+
* A public documentation MCP endpoint, over the same stateless transport.
|
|
209
|
+
*
|
|
210
|
+
* Deliberately has no `actor` and no `allowAnonymous`. The full handler refuses
|
|
211
|
+
* to start without one of them because it serves writes, uploads and approval
|
|
212
|
+
* decisions; this one serves documentation, so there is nothing to authenticate
|
|
213
|
+
* and nothing to accidentally leave open. That is the point of it being a
|
|
214
|
+
* separate function: the closed endpoint gains no new way to be opened.
|
|
215
|
+
*
|
|
216
|
+
* Mount it at `/mcp` on the docs domain, which is where clients look —
|
|
217
|
+
* Mintlify generates one there for every site it hosts, and Cloudflare runs a
|
|
218
|
+
* documentation server separately from its authenticated API server.
|
|
219
|
+
*/
|
|
220
|
+
declare function createDocsMcpHandler(options: DocsMcpOptions): GraftMcpHandler;
|
|
146
221
|
|
|
147
222
|
/**
|
|
148
223
|
* The self-teaching error knowledge base behind the `explain_error` tool.
|
|
@@ -170,6 +245,12 @@ declare function explainCode(code: string): ErrorExplanation | undefined;
|
|
|
170
245
|
* `createGraftMcp` builds the server; `serveStdio`
|
|
171
246
|
* binds it to stdio for `.mcp.json` / `graft mcp`; `createGraftMcpHandler`
|
|
172
247
|
* serves it over Streamable HTTP as a stateless `Request → Response` handler.
|
|
248
|
+
*
|
|
249
|
+
* `createDocsMcp` / `createDocsMcpHandler` build the other one: a public,
|
|
250
|
+
* read-only documentation server for `/mcp` on a docs domain. It is a separate
|
|
251
|
+
* factory rather than a flag, so the authenticated endpoint gains no new way to
|
|
252
|
+
* be opened.
|
|
253
|
+
*
|
|
173
254
|
* See docs/design-notes/agent-mcp.md.
|
|
174
255
|
*/
|
|
175
256
|
|
|
@@ -184,4 +265,4 @@ declare function explainCode(code: string): ErrorExplanation | undefined;
|
|
|
184
265
|
*/
|
|
185
266
|
declare function serveStdio(server: McpServer): Promise<void>;
|
|
186
267
|
|
|
187
|
-
export { ERROR_KNOWLEDGE, type ErrorExplanation, type GraftMcpHandler, type GraftMcpHandlerOptions, type GraftMcpOptions, createGraftMcp, createGraftMcpHandler, explainCode, serveStdio };
|
|
268
|
+
export { type DocsMcpOptions, ERROR_KNOWLEDGE, type ErrorExplanation, type GraftMcpHandler, type GraftMcpHandlerOptions, type GraftMcpOptions, createDocsMcp, createDocsMcpHandler, createGraftMcp, createGraftMcpHandler, explainCode, serveStdio };
|