This walkthrough connects Visual Studio Code directly to the Cloudflare API using the Cloudflare MCP server ↗. By the end, you can create a DNS record by typing a sentence, without leaving the editor.
The Cloudflare MCP server at mcp.cloudflare.com exposes the Cloudflare API to any MCP-capable agent. The Visual Studio Code Copilot agent connects to it, and you run API calls from natural language.
For the condensed version, refer to the Visual Studio Code quick start.
- Visual Studio Code, fully up to date. A version mismatch between the editor and the Copilot extension is the most common source of agent-mode errors.
- GitHub Copilot. Any GitHub account works, and the free tier is enough.
- A Cloudflare account you are comfortable pointing an agent at. Use a demo account. The reason becomes clear at the authorization step.
-
Confirm your Visual Studio Code version
Open Visual Studio Code and select Help > About. Confirm you are on a current build. If an Update button appears in the title bar, select it and let Visual Studio Code restart before continuing.

-
Sign in to Copilot
Select the Copilot icon in the Status Bar, select Use AI Features, then sign in with a GitHub account. Visual Studio Code opens your browser to authorize.

-
Authenticate to Copilot
Follow the browser pages to authenticate to GitHub.

-
Create a folder and open it
Create an empty folder for this project, then open it in Visual Studio Code with File > Open Folder. For example,
~/cloudflare-api-mcp/.
-
Create the configuration file
Inside the folder, create one file:
.vscode/mcp.json. Typing.vscode/mcp.jsonin the Explorer creates the folder and file together.
Paste the following into the file, then save:
{ "servers": { "cloudflare-api": { "type": "http", "url": "https://mcp.cloudflare.com/mcp" } } } -
Start the server
After you save the file, a Start link appears on the
cloudflare-apiserver definition. It looks like a comment, but it is a button (a CodeLens ↗). Select it, then allow the authentication prompt. Your browser opens the Cloudflare authorization page.
-
Choose an access template
The authorization page is where you decide what the agent can access. This example selects Full access to modify DNS records. You can also start with Read only or build a Custom permission set. Scope the grant to a single account, then review what you are granting.
Before you authorize, know two things. Full access lets the agent create and delete real resources, which is why this belongs on a demo account. You can revoke the grant at any time from the dashboard under My Profile > Access Management > Connected Applications, which is also the page to visit if a re-authorization behaves unexpectedly.
-
Verify permissions and authorize
Review the list of permissions, then select Authorize to let the Cloudflare API interact with your account.


-
Open Copilot Chat
If Copilot is minimized, open it with View > Chat.

-
Confirm the server is running
The server now shows as running. The CodeLens reads Running | 3 tools. Three tools is correct, not a broken install: the server uses a search-and-execute pattern instead of registering thousands of individual endpoints.

-
List your zones
In Copilot Chat, set the mode to Agent, then ask it to list your zones. The agent requests your approval before running the call and returns a live list of every domain in the account.
List zones in my accountRan Cloudflare API Code Executor - Zones returned: 1 - Zone: cloudflaredemo.net — id: <ZONE_ID> — status: active -
Create a DNS record
Ask the agent to create a DNS AAAA record and turn on the Cloudflare proxy. This example points
test.cloudflaredemo.netat100::, a reserved placeholder address from the IPv6 discard prefix0100::/64(RFC 6666 ↗). Because the record is proxied, Cloudflare intercepts requests before they reach this address. Approve the tool call (Always Allow), and the agent reports the record created.
Create a AAAA record for test.cloudflaredemo.net pointing to 100:: and enable the proxy.Ran Cloudflare API Code Executor - Record created: test.cloudflaredemo.net - Type: AAAA - Value: 100:: - Proxied: true - Record ID: <RECORD_ID>Do not rely on the agent's report alone. Open the dashboard and check the zone.

-
Verify DNS propagation
Ask the Cloudflare MCP server to verify that the record propagated.
Verify DNS propagation for test.cloudflaredemo.netRan: dig @1.1.1.1 test.cloudflaredemo.net AAAA +short - Result: DNS resolves to Cloudflare IPv6 addresses (proxy active). - Resolvers returning AAAA: 1.1.1.1, 8.8.8.8, 9.9.9.9 - 2606:4700::6812:2f3 - 2606:4700::6812:3f3 -
Delete the DNS record
You can delete the record as easily as you created it.
Delete test.cloudflaredemo.netRan Cloudflare API Code Executor Deleted the DNS record for test.cloudflaredemo.net.
You now have an AI agent with read and write access to Cloudflare services in the account, driven entirely from Visual Studio Code.
- Visual Studio Code quick start — condensed setup, tips, FAQ, and troubleshooting.
- Cloudflare MCP server ↗ — domain-specific MCP servers.
- Cloudflare API — the full REST API reference.