Skip to content

RFC: Progressive Type-Feedback MCP target (--target mcp) - #62

Draft
teamchong wants to merge 4 commits into
cloudflare:mainfrom
teamchong:rfc/mcp
Draft

teamchong wants to merge 4 commits into
cloudflare:mainfrom
teamchong:rfc/mcp

Conversation

@teamchong

@teamchong teamchong commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Adds rfcs/mcp.md specifying the Progressive Type-Feedback MCP target (--target mcp) — exposing the generated TypeScript SDK via search and execute MCP tools, forge://sdk resources, and pre-flight compiler diagnostics with 1-level .d.ts definitions.

Comment thread rfcs/mcp.md Outdated

`forge <spec> --target mcp --out <dir>` generates a Model Context Protocol (MCP) runtime (`mcp.ts` and `_/mcp.ts`) layered on top of the generated TypeScript SDK (`--target ts`).

Instead of emitting one MCP tool per OpenAPI operation or requiring the model to filter raw OpenAPI JSON in JavaScript, the server exposes the generated TypeScript SDK through two MCP tools (`search` and `execute`) and browsable MCP resources (`resources/list`, `resources/templates/list`, `resources/read`).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need both options here. Code mode native clients need direct tools, naive clients benefit from codemode tools.

Comment thread rfcs/mcp.md Outdated

Large OpenAPI descriptions (thousands of operations and models) break standard MCP tool generation in two ways:

1. **One tool per operation overflows context.** Emitting 3,000+ tool schemas produces megabytes of `tools/list` JSON, exceeding client tool limits and degrading tool selection accuracy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not entirely true anymore with tool search and client codemode. This is a client/agent implementation detail now.

Comment thread rfcs/mcp.md
Large OpenAPI descriptions (thousands of operations and models) break standard MCP tool generation in two ways:

1. **One tool per operation overflows context.** Emitting 3,000+ tool schemas produces megabytes of `tools/list` JSON, exceeding client tool limits and degrading tool selection accuracy.
2. **Raw OpenAPI `search` + `execute` is brittle.** Exposing `search` and `execute` over raw `spec.paths` forces the model to write custom JavaScript filters against deeply nested OpenAPI JSON and hand-craft `fetch(path, body)` calls without static type checking. A single `snake_case` vs `camelCase` mistake or nested field error causes a live HTTP `400`/`404` round-trip.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also maybe not true. I would love to validate that the models are better at using a generated sdk they have never seen before rather than a hierarchical open api spec which can be easily expressed in types (in training data)

Comment thread rfcs/mcp.md
└── Valid ──► Calls Forge TS Transport
```

1. **Resources (`forge://sdk`)** expose the SDK group tree (`resources/list`) and a URI template (`forge://sdk/{query}`) so MCP clients can browse groups, methods, and models directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very weird use of resources. There is a draft for something called MCP groups which sounds like what you are looking for.

Comment thread rfcs/mcp.md Outdated
```

1. **Resources (`forge://sdk`)** expose the SDK group tree (`resources/list`) and a URI template (`forge://sdk/{query}`) so MCP clients can browse groups, methods, and models directly.
2. **`search({ query? })`** inspects a 1-level `.d.ts` TypeScript declaration for any SDK group, method, or model, or searches across all SDK paths, HTTP routes, summaries, and descriptions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would this search work. IMO we should just get the model to write code. I made the original server this way after spending literally years evaling recommendation/search systems. I didnt want to do that here. Interested if you have a different opinion.

Comment thread rfcs/mcp.md

1. **Resources (`forge://sdk`)** expose the SDK group tree (`resources/list`) and a URI template (`forge://sdk/{query}`) so MCP clients can browse groups, methods, and models directly.
2. **`search({ query? })`** inspects a 1-level `.d.ts` TypeScript declaration for any SDK group, method, or model, or searches across all SDK paths, HTTP routes, summaries, and descriptions.
3. **`execute({ code, params? })`** runs JavaScript/TypeScript against the wrapped `client`. Returning an uninvoked namespace or method inspects its `.d.ts`; calling `await client.<group>.<method>(...)` validates arguments before making an HTTP request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validation on the server is not that interesting imo. I played with this but it added latency when actually it is normally solved when the model just calls the api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants