--- title: "AI & MCP Mocking with MockServer" shortTitle: "AI & MCP Overview" description: "MockServer supports three AI modes: MCP control plane for AI assistants, mocking AI/LLM services, and proxying/observing AI traffic." layout: page pageOrder: 0 section: 'AI & MCP' subsection: true sitemap: priority: 0.9 changefreq: 'monthly' lastmod: 2026-06-29T00:00:00+00:00 keywords: "mockserver ai, mcp mockserver, mock llm api, ai mocking, model context protocol, ai traffic inspection, openai mock, anthropic mock" schema_faq: - question: "What is MCP in MockServer?" answer: "MockServer includes a built-in MCP (Model Context Protocol) server at /mockserver/mcp. This lets AI coding assistants like Claude Code, Cursor, and Windsurf create mock expectations, verify requests, and debug HTTP failures by asking in plain English — no glue code required." - question: "Can I test an AI agent without paying for API calls?" answer: "Yes. MockServer's LLM Response Mocking feature lets you return realistic fake responses from OpenAI, Anthropic, Gemini, Azure OpenAI, Bedrock, and Ollama — with provider-correct formatting and SSE streaming. Your agent under test cannot tell the difference from the real API." - question: "How do I mock the OpenAI or Anthropic API with MockServer?" answer: "Use MockServer's LLM Response Mocking page. You can create single-turn completions, multi-turn scripted conversations, failover scenarios, and adversarial responses via the create_expectation MCP tool, the REST API, or any of the client libraries. All responses are deterministic and never call the real provider." - question: "Which MockServer AI page do I need?" answer: "There are three modes: (1) If you want your AI assistant to control MockServer — create mocks, verify calls, debug failures — start with MCP Setup. (2) If you want MockServer to return fake LLM or AI-protocol responses to your application under test, see LLM Response Mocking or AI Protocol Mocking. (3) If you want to proxy and inspect your AI agent's real API calls, see AI Traffic Inspection." - question: "Does MockServer support MCP server mocking (not just the MCP control plane)?" answer: "Yes, these are two separate things. MockServer's own MCP control plane lets AI assistants drive MockServer. Separately, the AI Protocol Mocking feature lets you stand up a fake MCP server or A2A agent for your application to connect to — so you can test your MCP client without running a real MCP server." - question: "What AI coding assistants work with MockServer's MCP integration?" answer: "Claude Code, Cursor, Windsurf, Cline, Continue, and OpenCode are all supported via the Streamable HTTP MCP transport. Programmatic MCP clients such as LangChain and LangGraph also work. Any tool that does not support MCP can use MockServer's OpenAPI specification as a REST API fallback." ---

MockServer helps with AI in three distinct ways. Pick the mode that matches your goal:

I want to… Use
Mode 1 — MockServer controlled by AI (AI coding assistant drives MockServer via MCP)
Connect Claude Code, Cursor, Windsurf, Cline, or OpenCode to MockServer MCP Setup
See all MCP tools my assistant can call (create_expectation, verify_request, etc.) MCP Tools Reference
Ask my assistant to capture traffic and explain why an API call failed Debugging with AI
Have my assistant verify recorded traffic or run contract/resiliency tests Contract Verification
Use MockServer from an AI tool that does not support MCP (ChatGPT Actions, Copilot, etc.) OpenAPI for AI (REST fallback)
Mode 2 — MockServer mocking AI services (return fake LLM or agent-protocol responses)
Mock OpenAI, Anthropic, Gemini, Bedrock, Azure OpenAI, or Ollama responses LLM Response Mocking
Stand up a fake MCP server or A2A agent for my application to connect to AI Protocol Mocking (MCP & A2A)
Mode 3 — MockServer observing / optimising AI traffic (proxy real API calls)
Proxy and record my AI agent's real LLM calls (prompts, tokens, tool calls, streamed responses) AI Traffic Inspection
Analyse captured LLM traffic and get costed advice on reducing inference spend LLM Cost Optimisation

Three ways MockServer works with AI: an AI assistant controls MockServer via MCP; MockServer mocks AI services (fake LLM/MCP/A2A); and MockServer observes AI traffic as a transparent proxy.

The three modes are independent — you can use any combination of them. For example, you might use Mode 3 to capture real LLM traffic during development, Mode 2 to replay it deterministically in CI, and Mode 1 to let your AI assistant create the mock expectations for you.

{% include_subpage _includes/ai_see_also.html %}