Back to Exercises
Build MCP Server
Create a custom MCP server that composes multiple operations into a single tool.
Objectives
- Design an MCP server for composed operations
- Implement tool definitions with proper schemas
- Handle JSON-RPC communication
- Test server with Claude Code integration
Beads Tasks
Create these tasks in Beads before starting. You learn Beads by using Beads.
bd create "Praxis: Build MCP server for [domain]" --type=feature--labels=learn,advancedbd create "Design tool composition—what operations merge?" --type=task--labels=learnbd create "Define JSON schema for tool inputs" --type=task--labels=learnbd create "Implement stdio transport handler" --type=task--labels=learnbd create "Implement tool execution logic" --type=task--labels=learnbd create "Test with Claude Code integration" --type=task--labels=learnClaude Code Prompt
Copy this prompt into Claude Code to build YOUR own version:
## Setup: Track this exercise with Beads
```bash
bd create "Praxis: Build MCP server for [domain]" --type=feature --labels=learn,advanced
bd create "Design tool composition—what operations merge?" --type=task --labels=learn
bd create "Define JSON schema for tool inputs" --type=task --labels=learn
bd create "Implement stdio transport handler" --type=task --labels=learn
bd create "Implement tool execution logic" --type=task --labels=learn
bd create "Test with Claude Code integration" --type=task --labels=learn
```
---
Help me build MY own MCP server for [DOMAIN].
I'm creating a custom MCP server that extends Claude Code for my specific use case. Guide me through:
1. **Identify composed operations**:
What operations do I frequently chain together?
- Read config → validate → apply?
- Query database → transform → cache?
- Fetch API → parse → update local state?
List 2-3 operations that should become single tools.
2. **Design tool schemas**:
For each tool, define:
```typescript
{
name: "my_tool",
description: "What this tool does",
inputSchema: {
type: "object",
properties: {
// Define inputs
},
required: ["..."]
}
}
```
3. **Set up the project**:
```bash
mkdir my-mcp-server && cd my-mcp-server
npm init -y
npm install @modelcontextprotocol/sdk
```
4. **Implement the server**:
Create src/index.ts with:
- Server initialization
- Tool registration
- stdio transport handler
- Tool execution logic
5. **Handle the protocol**:
- Parse JSON-RPC requests
- Return properly formatted responses
- Handle errors gracefully
6. **Test locally**:
- Add to Claude Code settings
- Invoke tools and verify output
- Debug any issues
7. **Document MY MCP server**:
- What problem does it solve?
- How do I use each tool?
- What are the gotchas?
Domain: [YOUR_DOMAIN - e.g., "project management", "data pipeline", "content publishing"]
Operations to compose: [YOUR_OPERATIONS] Your Solution
Write code that addresses the objectives above. Apply the principles from the Advanced path.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15