Repository navigation
feat(forge-mcp): generate MCP tools with a forge plugin and serve them over Streamable HTTP - #53
Closed
mattzcarey wants to merge 2 commits into
Closed
mattzcarey wants to merge 2 commits into
mattzcarey wants to merge 2 commits into
Conversation
…m over Streamable HTTP @cloudflare/forge-mcp has two halves. A TypeScript forge plugin turns the document into a tool catalogue, mcp-tools.json: one tool per method, with a self-contained JSON Schema input, annotations from the HTTP method, and the route its arguments take. A runtime on the MCP TypeScript SDK serves a catalogue with low-level tools/list and tools/call handlers. The README documents how methods become tools. example/ serves the Cloudflare API's catalogue (3,053 tools from the latest openapi.forge.json) from a Worker.
A tool's extensions carry a plugin's own data, such as the permissions a method needs, and are never sent to clients. catalogueTools(catalogue) gives a server the tools/list payload and name lookup when it lists other tools too. The package now builds to dist/ (JavaScript and declarations), which its exports point to, so it works from node_modules.
Member
Author
|
Closing for now. We'll keep working on this on a branch and try it in production behind |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
@cloudflare/forge-mcp: a TypeScript forge plugin that turns an OpenAPI document into an MCP tool catalogue (mcp-tools.json), and a runtime on the MCP TypeScript SDK that serves a catalogue over Streamable HTTP. The README spells out how methods become tools, as asked for on #49.This is the TypeScript, HTTP-only counterpart to #49. A Worker on the TS SDK can serve the generated tools with its own auth in front, and the catalogue is plain data, so the same file could back other runtimes.
src/tools.ts,src/schema.ts): one tool per non-deprecated method. Hidden methods are included, because a client can only call whattools/listreturns. Each tool has the group path plus method name in snake case, a self-contained JSON Schema 2020-12 input with only the$defsit reaches, and hints from the HTTP method. Methods with a required non-JSON body are skipped and listed inskippedwith the reason.catalogueFile(forge, { include, name, transform })is the hook for writing your own plugin.src/server.ts,src/request.ts):createForgeMcpHandler({ catalogue, authorize })returns afetch.tools/listis built once per catalogue, andtools/callsubstitutes path parameters, serializes the query informstyle and sendsbodyas JSON. A non-2xx response is anisErrorresult.serveCatalogueputs the same tools on an existing server.example/): a Worker serving the Cloudflare API.pnpm example:generateruns the plugin on the latestopenapi.forge.json.On the latest Cloudflare release, the plugin writes 3,053 tools in about 1.5 s; 27 methods are skipped for non-JSON bodies. The example Worker is 671 KB gzipped. I connected the MCP TS client to it under
wrangler dev:tools/listreturned all 3,053 tools in 112 ms, andaccounts_listandzones_listsucceeded against the live API with an OAuth token. Unit tests ran (pnpm --filter @cloudflare/forge-mcp test).