Visual Studio Code + Cloudflare·续
Optimize my Worker to serve WebP images with responsive resizing using Cloudflare Images.
Add mTLS authentication and schema validation to protect my API endpoints.
Tips
- The Cloudflare API MCP server uses Code Mode — the agent writes JavaScript against a typed API to reach any of 2,500+ endpoints in \~1,000 tokens. That is why you see only three tools registered, not thousands.
- Visual Studio Code's MCP configuration uses
serversas the root key. Configurations copied from other agents (Cursor, Claude Desktop) usemcpServersand will not work in Visual Studio Code. - Scope the OAuth grant to a single account, and start with Read only or a Custom permission set before granting Full access.
- Revoke the grant at any time from the Cloudflare dashboard under My Profile → Access Management → Connected Applications.
FAQ
<details>
<summary>Why does the MCP server only show three tools?
</summary>
The Cloudflare API specification is roughly two million tokens, which is far too large to hand an agent directly. The Cloudflare MCP server uses a code-execution pattern: the agent gets a tool to search the API spec and a tool to execute calls, and the spec stays server-side. Three tools is the correct, healthy state.
</details>
<details>
<summary>Does this only work with Visual Studio Code?
</summary>
No. The same server URL (<code>https://mcp.cloudflare.com/mcp</code>) works in Claude Code, Cursor, Claude Desktop, or any MCP-capable client. Visual Studio Code is one option among many.
</details>
<details>
<summary>Can I use a Cloudflare API token instead of OAuth?
</summary>
Yes. You can pass a Cloudflare API token as a bearer credential, which makes sense for CI/CD or shared automation. For interactive editor use, OAuth is the recommended path. API tokens using Client IP Address Filtering are not supported.
</details>
<details>
<summary>Do I need GitHub Copilot to use MCP in Visual Studio Code?
</summary>
Copilot Chat is the MCP client used in this guide, so yes — you need Copilot (or another MCP-capable extension) to actually drive the server. Visual Studio Code itself provides the MCP configuration and lifecycle, but the chat UI comes from Copilot.
</details>
Troubleshooting
<details>
<summary>Chat throws 'Cannot read properties of undefined'
</summary>
The Visual Studio Code build and the Copilot extension are out of sync. Update Visual Studio Code from the blue button in the title bar, let it restart, and try again.
</details>
<details>
<summary>Writes fail with API error 10000, but reads work
</summary>
The OAuth grant is read-only even though you intended to grant full access. This can happen if you authorize more than once — subsequent flows can silently come through with a reduced scope. Revoke the application under My Profile → Access Management → Connected Applications in the Cloudflare dashboard, sign out of the MCP session in Visual Studio Code (the account icon at the bottom of the activity bar), then start the server again.
</details>
<details>
<summary>No Start button appears in mcp.json
</summary>
Check the root key in the JSON. Visual Studio Code requires <code>servers</code>, not <code>mcpServers</code>. Also confirm the file is at <code>.vscode/mcp.json</code> inside the open folder, not at the folder root.
</details>
<details>
<summary>The agent suggests creating an API token to work around an error
</summary>
Decline. If authentication is broken, the fix is the OAuth grant, not pasting a bearer token into a chat window. Follow the API error 10000 troubleshooting steps to re-grant cleanly.
</details>
<details>
<summary>401 errors in the Visual Studio Code logs
</summary>
Expected behavior until you select Allow in this Session in the Copilot Chat authorization prompt.
</details>
Build agents on Cloudflare
Cloudflare is not just a deploy target for agents, it is a full stack for building your own.
Agents SDK Stateful AI agents with state, scheduling, RPC, email, streaming chat — and the Code Mode SDK for token-efficient tool use.Learn more Build an MCP server Ship a remote MCP server on Workers with OAuth, durable state, and streamable HTTP transport.Learn more Workers AI Run open-source LLMs, embedding models, and image models at the edge. Use it as your agent's model provider.Learn more Worker Loader Load user-generated code into isolated Workers on demand. The secure sandbox behind Code Mode.Learn more
Other agents

Anthropic<h3>Claude Code</h3>Terminal-based coding agent that understands your codebase, runs commands, edits files, and manages git. Made by Anthropic.View guide 
OpenAI<h3>Codex</h3>OpenAI coding agent available as a terminal CLI and desktop app. It reads and writes files, runs commands, and browses the web in a sandbox.View guide 
Cursor<h3>Cursor</h3>AI-first IDE built on VS Code with multi-file Composer edits and background agents. Made by Cursor.View guide 
GitHub<h3>GitHub Copilot</h3>Editor extension and CLI with agent mode, workspace context, and native PR integration. Made by GitHub.View guide 
Anomaly<h3>OpenCode</h3>Open-source terminal agent with a rich TUI that works with 75+ LLMs. Made by Anomaly.View guide 
Mistral AI<h3>Vibe</h3>Coding agent for terminal, IDE, and cloud workflows that reads files, runs commands, writes code, and opens pull requests. Made by Mistral AI.View guide 
Cognition<h3>Devin</h3>A full IDE with an agent manager built in — the command center for managing all your agents in one place. Made by Cognition.View guide 
Command Code<h3>Command Code</h3>Command Code is one of the most used coding agents for open models. It automatically learns your coding taste and self-improves as you work.View guide 
LM Studio<h3>Bionic</h3>Powerful agent for coding and work. Natively local, with open models in the cloud. By LM Studio.View guide 
Factory<h3>Droid</h3>Model-agnostic coding agent that plans, edits files, runs commands, and automates CI, from the terminal, desktop app, or cloud. Made by Factory.View guide
Was this helpful?
YesNo
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/agent-setup/visual-studio-code/#page","headline":"Visual Studio Code + Cloudflare","description":"Free, open-source code editor with native Model Context Protocol (MCP) client support and Copilot Chat integration. Made by Microsoft.","url":"https://developers.cloudflare.com/agent-setup/visual-studio-code/","inLanguage":"en","image":"https://developers.cloudflare.com/agent-setup/visual-studio-code/og.png?v=dd0fbeee502b48a4","dateModified":"2026-07-27","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: A screenshot-by-screenshot guide to connecting Visual Studio Code to the Cloudflare API through the Cloudflare MCP server, then creating, verifying, and deleting a DNS record with natural language. title: Visual Studio Code detailed walkthrough image: https://developers.cloudflare.com/agent-setup/visual-studio-code/detailed-walkthrough/og.png?v=9bc737509ef11abe
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/agent-setup/llms.txt
Use this file to discover all available pages before exploring further.
