--- title: AI Protocol Mocking (MCP & A2A) description: Mock MCP servers and A2A agent-to-agent protocol endpoints in MockServer to test AI integrations without calling real services. shortTitle: AI & MCP Mocking layout: page pageOrder: 5 section: 'AI & MCP' subsection: true sitemap: priority: 0.8 changefreq: 'monthly' lastmod: 2026-05-07T00:00:00+00:00 keywords: "mock mcp server, a2a protocol mocking, mock agent to agent, sse websocket mock" schema_faq: - question: "How do I mock an MCP server with MockServer?" answer: "Use MockServer's SSE response support (httpSseResponse) to return Server-Sent Events from any path. Combine it with JSON-RPC response matchers to handle MCP's Streamable HTTP protocol. Your AI client under test connects to MockServer instead of a real MCP server and receives deterministic tool-list and tool-call responses." - question: "What is A2A protocol mocking?" answer: "A2A (Agent-to-Agent Protocol) is a Google-defined standard for agent interoperability. MockServer can stand up a fake A2A agent that serves the /.well-known/agent.json discovery card, handles tasks/send and tasks/get JSON-RPC calls, and returns scripted task responses. Use this to test an A2A client without running a real agent." - question: "Can MockServer mock SSE or WebSocket AI endpoints?" answer: "Yes. MockServer supports SSE responses (httpSseResponse) with per-event delays, and WebSocket mocking that performs the upgrade handshake and streams text or binary frames. Both are commonly used by LLM streaming APIs, MCP's Streamable HTTP transport, and real-time agent protocols." - question: "How is mocking an MCP server different from MockServer's own MCP control plane?" answer: "They are completely separate features. MockServer's own MCP control plane (at /mockserver/mcp) lets AI coding assistants like Claude Code or Cursor control MockServer — creating expectations, verifying calls, and debugging traffic. The AI Protocol Mocking feature lets you stand up a fake third-party MCP server that your application under test connects to. One is about controlling MockServer; the other is about mocking an external service." ---
MockServer can mock AI protocol servers — including MCP (Model Context Protocol) servers and A2A (Agent-to-Agent Protocol) agents — enabling you to test AI clients against predictable mock services without running real AI infrastructure.
This is distinct from MockServer's built-in MCP control plane (which lets AI assistants control MockServer). These features let you mock other people's MCP and A2A servers. For mocking LLM API responses (OpenAI, Anthropic, Gemini, etc.) with provider-correct formatting and streaming, see LLM Response Mocking.
