Wire an MCP Server into a Claude Agent Loop
Intermediate · 35 minutes · 5 tasks, checked automatically · 100 points
Build a working Model Context Protocol (MCP) server that exposes real tools, then wire it into a Claude-powered agent loop so the frontier model discovers and calls your tools unprompted. You will write the server, inspect it with the MCP Inspector, author an agent that speaks the MCP stdio transport, and watch Claude autonomously choose and invoke your custom tools to answer a prompt it could not answer alone.
What you’ll learn
- Implement an MCP stdio server in Node.js that registers at least two callable tools
- Verify the server's tool manifest with the MCP Inspector CLI before wiring it to any agent
- Write a Node.js agent that launches the MCP server as a child process, performs the MCP initialize handshake, and calls the Anthropic Messages API with the discovered tool schemas
- Observe Claude autonomously emit a tool_use block and receive the tool result in a follow-up turn
- Confirm the full round-trip by checking a persisted results file written by the agent
How this lab works
- Start the lab: One click starts a sandbox with a local model and the agent’s toolbox: no API key and no token bill.
- Work through 5 tasks: Each task says what to build or fix. You do it yourself, in a real terminal, with hints when you get stuck.
- Check your work: Check my work inspects the agent, its config and its output, and says what passed and what to fix.
- Finish and keep going: 100 points, your progress saved, and the next lab to try.
What it runs on
- Runs: Locally, against a model on your computer: no API key, no tokens
- Model: claude-sonnet-4-6
- Open source: github.com/modelcontextprotocol
What you need
- A free LearnXops account
- The LearnXops desktop app for macOS, Windows or Linux
- An Anthropic API key added once in the LearnXops Agent Playground (stored in the OS keyring, never re-entered)
- A hosted sandbox created in the Agent Playground — the key arrives as ANTHROPIC_API_KEY inside the toolbox container
Topics: mcp, model-context-protocol, claude, anthropic, tool-use, agent-loop, stdio-transport, nodejs, integration, frontier-model
Create a free account to start this lab.
Keep going
- Connect Hermes to an MCP Server and Call a Tool
- MCP Prompts with Arguments: Build a Parameterised Workflow Server
- Validate MCP Tool Inputs with JSON Schema and Return Protocol Errors
- Wrap a Local Database as an MCP Server with Read-Only Query Tools and a Schema Resource
- Expose MCP Resources and Tools, Then Fetch a Resource by URI
- Read the MCP Handshake: Initialize, Capability Negotiation, and Tool Listing