-
Notifications
You must be signed in to change notification settings - Fork 331
Mcp code mode #3510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aditya520
wants to merge
7
commits into
main
Choose a base branch
from
mcp-code-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Mcp code mode #3510
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
735560f
docs(mcp): add code mode adoption plan
aditya520 e87a6e7
feat(mcp): implement Code Mode with search and execute tools
aditya520 fc97625
fix(mcp): address 6 Code Mode review issues
aditya520 b188620
fix(mcp): close VM escape, enforce async timeout, handle undefined re…
aditya520 8520863
fix(mcp): remove stale isolated-vm from lockfile
aditya520 f4e6929
chore(mcp) fix comments
aditya520 bddb3ae
fix(mcp): bridge async bindings through sandbox-realm Promises
aditya520 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Pyth MCP Code Mode Adoption Plan | ||
|
|
||
| ## Decision | ||
|
|
||
| Adopt Code Mode and host on Cloudflare Workers by default. | ||
|
|
||
| This is the shortest path to: | ||
| - Stable `search` + `execute` tool surface as APIs evolve | ||
| - Strong token security via server-side injection | ||
| - Full observability with low operational overhead | ||
|
|
||
| ## Why This Direction | ||
|
|
||
| - Code Mode keeps MCP tool count fixed while backend APIs grow. | ||
| - Server-side token injection avoids passing `access_token` in model-visible calls. | ||
| - Cloudflare execution sandboxing is production-ready for generated code workloads. | ||
| - Cloudflare access controls and centralized logging align with security requirements. | ||
|
|
||
| ## Architecture (Target) | ||
|
|
||
| - Expose Code Mode tools: | ||
| - `search` | ||
| - `execute` | ||
| - Keep existing traditional tools as fallback during rollout. | ||
| - Route `get_latest_price` through a wrapper that injects a server-managed token. | ||
| - Never expose the token in tool schema, prompt context, or user-provided arguments. | ||
|
|
||
| ## Hosting Recommendation | ||
|
|
||
| Primary: | ||
| - Cloudflare Workers + Dynamic Worker Loader | ||
|
|
||
| Fallback (only if Cloudflare is not allowed): | ||
| - Kubernetes + Node + `isolated-vm` + OpenTelemetry | ||
|
|
||
| ## Security Requirements | ||
|
|
||
| - Use one server-managed Pyth Pro token from a secret manager. | ||
| - Inject token only inside execution boundary. | ||
| - Block outbound network from generated code except approved tool proxy path. | ||
| - Enforce per-request timeouts and rate limits. | ||
| - Redact secrets from all logs and error payloads. | ||
|
|
||
| ## Observability Requirements | ||
|
|
||
| - Traces: | ||
| - MCP request span | ||
| - code execution span | ||
| - upstream API spans | ||
| - Metrics: | ||
| - execution latency (p50/p95/p99) | ||
| - sandbox timeout/error rates | ||
| - upstream error rates | ||
| - tool calls per execution | ||
| - response size | ||
| - Structured logs: | ||
| - `requestId`, `sessionId`, `clientName`, `toolsCalled`, `executionTimeMs` | ||
| - Dashboards: | ||
| - reliability | ||
| - security events | ||
| - Code Mode adoption and efficiency | ||
|
|
||
| ## Rollout Plan | ||
|
|
||
| 1. Add feature flag: `ENABLE_CODE_MODE`. | ||
| 2. Implement `search` and `execute` with token-injecting wrapper. | ||
| 3. Add tests for: | ||
| - token injection | ||
| - sandbox timeout/network blocking | ||
| - multi-step one-roundtrip execution | ||
| 4. Launch internal beta with fallback tools enabled. | ||
| 5. Make Code Mode default after stability and observability targets are met. | ||
|
|
||
| ## Exit Criteria for Default-On | ||
|
|
||
| - No token leakage in request/response/log pipelines. | ||
| - Sandbox timeout and error rates within SLO. | ||
| - Code Mode handles majority of complex multi-step queries. | ||
| - Traditional fallback remains available for client compatibility. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 README has misplaced Code Mode text under
### Buildand broken heading hierarchy with## SetupThe
### Buildsubsection (under## Local Development) now contains an orphaned Code Mode description sentence (Code Mode exposes these via...) instead of the build command. The build command was moved into a new## Setuptop-level section, which breaks the document hierarchy —## Setupsits at the same level as## Local Developmentbut the build instructions logically belong under### Build. The Code Mode sentence appears to belong in the## Modesor## Tools (Legacy mode)section instead.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.