DEV Community

Andrew Barnes
Andrew Barnes

Posted on

I Built My First AI Agent That Understands Bitcoin -- Here's How

I Built My First AI Agent That Understands Bitcoin -- Here's How

A beginner's guide to MCP, agentgateway, and bitcoin-mcp


I wanted to build an AI agent that could answer questions about Bitcoin. Not from a static FAQ -- I mean real-time data. Current block height. Mempool congestion. Fee estimates. Mining stats.

I figured this would take days of API wrangling, authentication headaches, and custom plumbing. It took 10 minutes.

Here's what I learned.

The Problem

AI models are smart, but they're stuck in the past. Ask Claude or GPT about the current Bitcoin block height and you'll get a polite "I don't have access to real-time data." Fair enough -- but what if you could give them that access?

That's what MCP does.

What is MCP?

Model Context Protocol (MCP) is an open standard that lets AI models call external tools. Think of it like USB for AI: a universal plug that connects any AI client to any data source. An MCP server exposes tools (like "get the current Bitcoin block height"). An MCP client (like Claude Desktop or a custom script) calls those tools. The AI model decides which tools to call based on your question.

The beauty is separation of concerns. The Bitcoin logic lives in the MCP server. The AI logic lives in the client. They speak the same protocol.

What is agentgateway?

agentgateway is a lightweight proxy that sits between your AI client and your MCP servers. Why do you need a proxy? A few reasons:

  • Protocol translation -- it can bridge different MCP transports (stdio, SSE, Streamable HTTP)
  • Routing -- it can fan out to multiple MCP servers from a single endpoint
  • Security -- it's where you'd add authentication, rate limiting, and audit logging in production

For our purposes, it gives us a clean HTTP endpoint that any MCP client can connect to.

The Stack

Here's what we're building:

AI Client  --->  agentgateway (port 3000)  --->  bitcoin-mcp (port 8000)
Enter fullscreen mode Exit fullscreen mode

Three components. Two commands to start. One config file.

Let's Build It

Step 1: Install bitcoin-mcp

pip install bitcoin-mcp
Enter fullscreen mode Exit fullscreen mode

That's the entire Bitcoin integration. bitcoin-mcp ships with 49 tools for querying the Bitcoin network, and it works out of the box -- no API keys, no local node required. It connects to the free Satoshi API by default.

Step 2: Start bitcoin-mcp

bitcoin-mcp --transport sse --port 8000
Enter fullscreen mode Exit fullscreen mode

This starts an MCP server on port 8000 using Server-Sent Events transport. Leave this terminal running.

Step 3: Get agentgateway

Download the binary from the agentgateway releases page for your platform.

Step 4: Create the Config

Save this as config-sse.yaml:

binds:
- port: 3000
  listeners:
  - routes:
    - policies:
        cors:
          allowOrigins: ["*"]
          allowHeaders: ["*"]
          exposeHeaders: ["Mcp-Session-Id"]
      backends:
      - mcp:
          targets:
          - name: bitcoin-mcp
            sse:
              url: http://localhost:8000/sse
Enter fullscreen mode Exit fullscreen mode

This tells agentgateway to listen on port 3000 and forward everything to bitcoin-mcp.

Step 5: Start agentgateway

./agentgateway -f config-sse.yaml
Enter fullscreen mode Exit fullscreen mode

Step 6: Connect

Open MCP Inspector:

npx @modelcontextprotocol/inspector
Enter fullscreen mode Exit fullscreen mode

Set the transport to Streamable HTTP, enter http://localhost:3000, and click Connect.

Go to the Tools tab. You'll see 49 tools. Click get_situation_summary and hit Call.

The "Aha" Moment

When I called get_situation_summary for the first time, I got back a wall of structured data: block height, hashrate, difficulty adjustment progress, mempool size, fee tiers, mining pool distribution. Real data. Live from the Bitcoin network.

I didn't write any Bitcoin code. I didn't parse any APIs. I didn't handle any authentication. I installed an MCP server, pointed a proxy at it, and connected.

That's when MCP clicked for me. The AI doesn't need to know how Bitcoin works. It just needs to know which tool to call. The MCP server handles everything else.

I tried more tools. get_fee_estimates told me exactly what fee to use for a transaction right now. analyze_mempool showed me the current congestion. get_mining_info gave me hashrate and difficulty data. Each one returned structured, accurate, real-time data.

Then I connected it to Claude Desktop (just a one-line config change) and asked in natural language: "What's the current state of the Bitcoin mempool?" Claude called the right tools automatically and gave me a clear, conversational summary backed by live data.

What I Learned

MCP is simpler than I expected. I kept looking for the catch -- the complex authentication step, the mandatory configuration file with 200 options, the thing that would take an hour to debug. It wasn't there. The protocol is genuinely simple.

agentgateway solves real problems. Without it, you'd need every AI client to support every MCP transport. With it, you expose one HTTP endpoint and route to any backend. It's the missing piece between "I have an MCP server" and "any client can use it."

The tool ecosystem is the killer feature. bitcoin-mcp alone has 49 tools. Imagine stacking multiple MCP servers -- weather, databases, APIs, Bitcoin -- all accessible through one gateway. That's where this gets powerful.

Separation of concerns matters. The AI model picks which tools to call. The MCP server implements the tools. The gateway handles routing and security. Each piece does one thing well.

What's Next

This starter example runs everything locally with no authentication. For production, you'd want:

  • Authentication -- agentgateway supports JWT validation and API keys
  • Rate limiting -- prevent abuse
  • Audit logging -- track what tools are being called and by whom

I'm also looking into publishing bitcoin-mcp to an MCP registry so anyone can discover and use it without knowing the GitHub URL.

Try It Yourself

The full code is in the hackathon repo. Clone it, follow the README, and you'll have a working Bitcoin AI agent in 10 minutes.

If you've been curious about MCP but haven't tried it yet -- this is your on-ramp. The barrier is genuinely low, and the payoff is seeing an AI agent answer questions with real-time data for the first time.


Built with bitcoin-mcp, agentgateway, and an unreasonable enthusiasm for Bitcoin tooling.

Top comments (0)