Sunday, April 5

MCP Server Architect: Stop Reinventing the Wheel Every Time You Build an MCP Server

If you’ve built more than one MCP server from scratch, you already know the pain. You spend the first hour not solving your actual problem — you spend it remembering whether session IDs should be bound to user identity, double-checking the JSON-RPC 2.0 batching spec, figuring out if your transport negotiation is correct, and debating whether your tool annotations are properly signaling destructive vs. idempotent operations. None of that is your domain problem. It’s protocol overhead, and it eats time you don’t have.

The MCP Server Architect agent changes that equation. It brings deep, opinionated knowledge of the full MCP specification (2025-06-18) into your Claude Code workspace so that protocol-level decisions become fast, correct, and consistent — every time. This agent doesn’t just suggest patterns. It implements them: proper JSON-RPC 2.0 transport layers, completion endpoints, tool annotations, session management with non-deterministic IDs, multi-stage Docker builds, and security scanning integration. You describe what your server needs to do. The agent handles the how-to-build-it-correctly part.

For senior developers, the value compounds quickly. You’re not just saving the hour you’d spend reading specs — you’re preventing the subtle bugs that come from misremembering them three months later.

When to Use the MCP Server Architect

This agent is marked as something to use proactively, which matters. Don’t wait until you’re stuck — invoke it at the start of any MCP server work. Specifically, reach for it when:

  • Designing a new MCP server from scratch. Before you write a single line of implementation code, use this agent to think through your tool interface design, capability declarations, and transport strategy. It will ask the right questions about your domain and use cases before recommending an architecture.
  • Adding Streamable HTTP transport to an existing stdio server. HTTP transport introduces Origin header validation, session management complexity, and SSE fallback considerations. This agent knows exactly how to layer that in cleanly.
  • Implementing the completion/complete endpoint. Completion support is one of the more underimplemented MCP features, and getting it right — declaring the capability, implementing the endpoint, returning intelligent suggestions — has real UX impact for the clients consuming your server.
  • Designing tool budgets for complex domains. When your server is wrapping an API with dozens of endpoints, you need intentional tool grouping. This agent understands the tradeoff between granular tools and high-level tools that chain operations.
  • Hardening a server for production. Authentication, input validation, connection pooling, multi-region deployment patterns, verbose-dev/quiet-prod logging, SBOMs — this agent knows the full production checklist and will apply it systematically.
  • Containerizing your MCP server. Multi-stage Docker builds for optimal image size and reproducible deployment are a standard output from this agent, not an afterthought.

Real-World Examples

Scenario 1: Building a New MCP Server for an Internal Data API

A backend engineer is building an MCP server that wraps a company’s internal REST API for querying project metrics. They want Claude to be able to fetch data, but they’re unsure how to structure the tools and whether to bother with HTTP transport or just use stdio.

Developer: I need to build an MCP server that wraps our internal metrics API.
It has about 40 endpoints — projects, sprints, commits, deployments, incidents.
Should I expose all of them as individual tools?

MCP Server Architect: No — 40 tools would be noisy and expensive to reason over.
Apply intentional tool budgeting. Group by workflow, not by endpoint.

Here's what I'd recommend for your domain:

tools:
  - get_project_summary(project_id, time_range) — aggregates project, sprint,
    and recent commit data in one call
  - get_deployment_health(project_id) — combines deployment and incident data
  - query_sprint_metrics(sprint_id) — focused sprint-level detail

This gives Claude high-level tools it can chain rather than 40 micro-calls.
Each tool should declare:
  annotations: { readOnly: true, idempotent: true }

For transport: start with stdio. Add Streamable HTTP when you need
multi-client or web-based access. I'll scaffold both with proper
Origin header validation on the HTTP layer. Want me to generate
the TypeScript scaffold with @modelcontextprotocol/sdk ≥1.10.0?

Scenario 2: Adding Completion Support to an Existing Server

A developer has an MCP server that exposes database query tools. They want to add argument completion so clients can suggest valid table names and column names when invoking tools.

Developer: My MCP server has a query_table tool that takes a table_name argument.
I want clients to get autocomplete suggestions for valid table names.
How do I implement that?

MCP Server Architect: You need to declare the completions capability and implement
the completion/complete endpoint. Here's the pattern in TypeScript:

// In your server capabilities declaration
const server = new McpServer({
  name: "database-server",
  version: "1.0.0",
  capabilities: {
    tools: {},
    completions: {}   // <-- declare it here
  }
});

// Handle completion requests
server.setRequestHandler(CompleteRequestSchema, async (request) => {
  const { ref, argument } = request.params;

  if (ref.type === "ref/tool" && ref.name === "query_table") {
    if (argument.name === "table_name") {
      const tables = await db.listTables();
      const matches = tables.filter(t =>
        t.startsWith(argument.value)
      );
      return {
        completion: {
          values: matches.slice(0, 10),
          hasMore: matches.length > 10,
          total: matches.length
        }
      };
    }
  }
  return { completion: { values: [] } };
});

Keep completion handlers fast — clients call these on keystroke.
Cache your table list with a short TTL. Want me to add column-level
completion scoped to the selected table as well?

Scenario 3: Production Hardening Before Deployment

A team is ready to deploy their MCP server to production and wants a checklist review.

Developer: We're about to deploy our MCP server. What do we need to check
before it goes live?

MCP Server Architect: Walk through these before you ship:

Security:
  ✓ Session IDs are non-deterministic and bound to user identity
  ✓ Origin header validated on all Streamable HTTP requests
  ✓ All tool inputs validated against JSON Schema before execution
  ✓ Dependencies scanned — run npm audit or pip-audit in CI
  ✓ SBOM generated for your container image

Transport:
  ✓ /mcp endpoint handles both GET and POST correctly
  ✓ SSE fallback tested with a legacy client
  ✓ JSON-RPC batching tested under load

Logging:
  ✓ All logs go to stderr, never stdout
  ✓ Verbose mode off in production (--log-level warn or equivalent)

Container:
  ✓ Multi-stage Docker build — builder stage separate from runtime stage
  ✓ Runtime image uses non-root user
  ✓ Secrets injected via environment, not baked into image

Versioning:
  ✓ Server version declared in capabilities matches package.json
  ✓ Changelog updated

I can generate a CI pipeline config that automates the security scanning
and SBOM steps if that's useful.

What Makes This Agent Powerful

Spec-Locked Knowledge

The agent explicitly references the MCP specification dated 2025-06-18. That’s not a minor detail — the MCP spec has evolved, and older implementation patterns have real incompatibilities with current clients. You get current-spec behavior by default.

Full Stack Coverage

Most agents cover one layer. This one covers the entire server lifecycle: requirements analysis, tool interface design, transport implementation, security hardening, performance optimization, containerization, and documentation. You don’t need a separate agent for each concern.

Intentional Defaults

The agent has opinions — good ones. It recommends TypeScript with @modelcontextprotocol/sdk ≥1.10.0 or Python with full type hints. It defaults to single /mcp endpoints, non-deterministic session IDs, stderr-only logging, and multi-stage Docker builds. These aren’t arbitrary choices — they’re the practices that prevent the classes of bugs that hit MCP servers in production.

Systematic Implementation Order

The agent follows a disciplined sequence: analyze requirements → design tool interfaces → implement transport → ensure security → optimize performance → test → document. It won’t let you skip ahead and write transport code before you’ve thought through your tool design.

How to Install the MCP Server Architect

Installation is straightforward. Claude Code automatically loads agents defined in your project’s .claude/agents/ directory. Here’s how to set it up:

  1. In your project root, create the directory .claude/agents/ if it doesn’t already exist.
  2. Create a new file at .claude/agents/mcp-server-architect.md.
  3. Paste the agent’s system prompt (the full agent body starting with “You are an expert MCP server architect…”) into that file and save it.
  4. Restart or reload Claude Code. The agent will be available automatically — no additional configuration required.

Once installed, you can invoke the agent by name in Claude Code when working on MCP server tasks, or simply begin describing your MCP server requirements and Claude Code will recognize the context and apply it proactively.

Conclusion and Next Steps

The MCP Server Architect agent is worth adding to any Claude Code workspace where MCP server development happens regularly. The upfront cost is five minutes of setup. The return is every future MCP server starting from a correct foundation rather than a blank file and a browser tab open to the spec.

Practical next steps: install the agent today, then open your current or next MCP server project and start with a requirements conversation. Let the agent ask you the right architecture questions before you write implementation code. If you have an existing server, run it through the production hardening checklist — you’ll almost certainly find at least one gap worth closing before your next deployment.

The protocol details are handled. Your job is the domain problem.

Agent template sourced from the claude-code-templates open source project (MIT License).

Share.
Leave A Reply