跳转到主要内容

OpenCode + Cloudflare

import { Steps } from "/components"; import AgentHeader from "/components/agent-setup/AgentHeader.astro"; import PlatformAccess from "/components/agent-setup/PlatformAccessSection.astro"; import ExamplePromptsList from "/components/agent-setup/ExamplePromptsList.astro"; import RandomPrompt from "/components/agent-setup/RandomPrompt.astro"; import TipsList from "/components/agent-setup/TipsList.astro"; import FAQList from "/components/agent-setup/FAQList.astro"; import FAQItem from "/components/agent-setup/FAQItem.astro"; import TroubleshootingList from "/components/agent-setup/TroubleshootingList.astro"; import TroubleshootingItem from "/components/agent-setup/TroubleshootingItem.astro"; import BuildAgentsCallout from "/components/agent-setup/BuildAgentsCallout.astro"; import OtherAgents from "/components/agent-setup/OtherAgents.astro";

Quick start

1. **Install OpenCode**
	Install OpenCode. For npm, Homebrew, Bun, Scoop, or Windows options, see the [OpenCode install guide](https://opencode.ai/docs/).

	```bash
	curl -fsSL https://opencode.ai/install | bash
	```

2. **Install Cloudflare Skills**

	```bash
	npx skills add https://github.com/cloudflare/skills
	```

3. **Add the Cloudflare MCP server**

	Add the Cloudflare MCP server to `.opencode.jsonc`. For domain-specific MCP servers, refer to [mcp-server-cloudflare](https://github.com/cloudflare/mcp-server-cloudflare). For the full Cloudflare API MCP server (Code Mode), refer to [cloudflare/mcp](https://github.com/cloudflare/mcp).

	```json
	{
	  "mcp": {
	    "cloudflare": { "type": "remote", "url": "https://mcp.cloudflare.com/mcp", "enabled": true }
	  }
	}
	```

4. **Launch OpenCode**

	Start OpenCode from the root of your project, where `wrangler.jsonc` or `cloudflare.config.ts` lives (if either exists).

	```bash
	opencode
	```

5. **Try a prompt**

	For example:

	<RandomPrompt />

Cloudflare platform access

Example prompts

Tips

  • The Cloudflare API MCP server uses Code Mode — OpenCode writes JavaScript to reach any of 2,500+ endpoints in ~1,000 tokens.
  • OpenCode supports 75+ LLMs — you can use Cloudflare Workers AI as the model provider for a fully Cloudflare-native workflow.
  • Use OpenCode's plan agent (Tab key) to break down complex Workers projects before coding.

FAQ

All three. Skills provide persistent Cloudflare expertise so OpenCode knows when to reach for Durable Objects vs KV, how to structure a Workers project, and when to call CLI vs API. The Cloudflare API MCP server handles platform operations (DNS, WAF, Zero Trust, R2 buckets). Wrangler handles local dev, deploys, and Workers-specific commands. The bundled `wrangler` Skill teaches OpenCode which to use. For tasks across the whole Cloudflare API, OpenCode can also use the [Cloudflare CLI](/cf/), `cf`. Yes. The [Cloudflare CLI](/cf/), `cf`, is in beta and covers the whole Cloudflare API and prints JSON output. Install it with `npm install -g cf`, sign in with `cf auth login`, and tell OpenCode to prefer it in `AGENTS.md`. Refer to [Use cf with AI agents](/cf/agents/). The first time OpenCode calls a Cloudflare tool, you will be redirected to authorize via OAuth and choose permissions. Yes. OpenCode supports 75+ model providers, including Cloudflare Workers AI. Configure your model in `.opencode.jsonc`. Yes. OpenCode is fully open source and available at github.com/anomalyco/opencode.

Troubleshooting

Verify the MCP configuration in `.opencode.jsonc` uses `"type": "remote"` with the correct URL. Run `opencode mcp list` to check connected servers. Point the agent directly at developers.cloudflare.com/llms.txt for a directory of every product, or developers.cloudflare.com/<product>/llms.txt for a product-specific index.

Build agents on Cloudflare

Other agents