What is an MCP Server? A Developer's Guide

You've seen "MCP" in Claude Code's settings and in Cursor's configuration. Here's what it actually is, why Anthropic introduced it, how it works across the major AI coding assistants — and how tools like PrePrompt use it to intercept prompts before the LLM ever sees them.

The Short Answer

Q: What is an MCP server?

A: An MCP server is a process that implements Anthropic's Model Context Protocol — an open standard that allows external tools to communicate with AI coding assistants like Claude Code and Cursor. MCP servers can expose tools (callable functions), resources (data the AI can read), and event hooks (like UserPromptSubmit) that the AI assistant invokes during a coding session.

Q: What does MCP stand for?

A: MCP stands for Model Context Protocol. It was introduced by Anthropic in late 2024 as an open standard for AI tool integration — allowing any external tool to communicate with any MCP-compatible AI assistant without bespoke integration work.

Why MCP Exists

Before MCP, every tool integration with an AI coding assistant was bespoke. If you wanted a custom context injector in Claude Code, you wrote a plugin in whatever format that specific IDE required. If you wanted the same tool in Cursor, you rewrote it in a different format. Windsurf and Zed each had their own approach.

MCP standardizes the protocol so that one implementation can work across all compatible hosts. The analogy is precise:

MCP is to AI coding assistants what LSP (Language Server Protocol) is to editors. One standard protocol; any compliant tool works with any compliant host.

An MCP server written for Claude Code also works in Cursor, Windsurf, and Zed — because they all implement the same protocol. PrePrompt is built this way: pip install preprompt works with all four IDEs from a single implementation.

How an MCP Server Works: The Technical Picture

The client-server model

MCP has two sides. The host (Claude Code, Cursor, Windsurf, Zed) is the client. The server is the external tool — PrePrompt, a database connector, a documentation fetcher, or anything else. The host discovers available servers via configuration files and starts them as subprocesses when needed.

What an MCP server can expose

The UserPromptSubmit Hook Is How PrePrompt Intercepts Prompts

The UserPromptSubmit hook fires every time a developer submits a prompt in Claude Code — before the prompt reaches the LLM. It is the hook that gives PrePrompt its interception capability.

The full request flow when you have PrePrompt installed:

User types prompt
    → UserPromptSubmit hook fires (PrePrompt subprocess)
        → classify_prompt()     ← local heuristic, <1ms, no API
        → if score < 38: passthrough unchanged
        → else: optimize() via Claude Haiku API
        → print optimized prompt + annotation box to stderr
        → write JSON sidecar to ~/.preprompt/pending/
    → Claude Code sends (possibly optimized) prompt to LLM
    → (on next MCP tool call)
        → flush_pending_hook_events() reads sidecars → SQLite

The hook never touches the SQLite database directly — that avoids lock contention with the running MCP server. The sidecar pattern (writing to ~/.preprompt/pending/ as JSON files) is the IPC mechanism between the hook subprocess and the MCP server process.

MCP Support Across IDEs

IDE MCP Support UserPromptSubmit Hook Config Location
Claude Code Full Yes — automatic ~/.claude/settings.json
Cursor Agent mode only Via MCP rules ~/.cursor/mcp.json
Windsurf Full Yes ~/.codeium/windsurf/mcp_config.json
Zed Full Yes ~/.config/zed/settings.json
VS Code Partial (GitHub Copilot) Not yet In development

The Cursor caveat is important: MCP tools only activate in Agent mode. If you are using Cursor's Ask or Plan modes, MCP servers are not invoked at all. PrePrompt's automatic interception requires Agent mode in Cursor.

How to Install an MCP Server: PrePrompt as an Example

The general pattern for installing any MCP server into Claude Code involves two steps: install the server, then register it in ~/.claude/settings.json. For PrePrompt specifically, one command handles both:

pip install preprompt
preprompt-install

preprompt-install detects which IDEs you have installed (Claude Code, Cursor, Windsurf, Zed) and writes the appropriate config to each. For Claude Code, it writes an mcpServers entry pointing to the Python module and a hooks.UserPromptSubmit entry pointing to the hook subprocess.

The resulting entry in ~/.claude/settings.json looks like this:

{
  "mcpServers": {
    "preprompt": {
      "command": "python",
      "args": ["-m", "mcp_server.server"],
      "env": { "ANTHROPIC_API_KEY": "your-key-here" }
    }
  },
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "",
        "hooks": [{ "type": "command", "command": "python -m cli.hook" }]
      }
    ]
  }
}

Frequently Asked Questions

How do I add an MCP server to Claude Code?

Edit ~/.claude/settings.json and add a mcpServers key. Each entry needs at minimum a command (the executable) and args (arguments to pass). Many MCP servers provide an install script that does this automatically — PrePrompt uses preprompt-install.

Does Cursor support MCP servers in all modes?

No. MCP tools only activate in Cursor's Agent mode. The Ask and Plan modes do not invoke MCP servers. This is a Cursor limitation, not an MCP limitation. If you are primarily using Cursor in Ask mode, PrePrompt's automatic interception will not fire — you can still use the preprompt-optimize CLI command manually.

Can MCP servers access my codebase?

Only if the MCP server is explicitly designed to do so and you configure it with access. PrePrompt does not read your codebase — it only sees the prompt text you submit. All logging is local to ~/.preprompt/history.db on your machine.

Is MCP an open standard?

Yes. The MCP specification is open and published by Anthropic at modelcontextprotocol.io. Any IDE can implement the protocol and any tool developer can build MCP servers. The growing MCP ecosystem means tools like PrePrompt work across multiple IDEs without IDE-specific code.

Further Reading