What Is an MCP Server? Model Context Protocol Explained
One standard way for AI apps to use your tools and data. Here's how MCP servers work, what they expose, how they connect, and where they go wrong.
MCP server vs REST API
|
MCP server |
REST API | |
|---|---|---|
|
Built for |
AI applications and agents |
Any software client |
|
Discovery |
Client lists tools, resources and prompts at runtime |
A developer reads docs or an OpenAPI spec |
|
Who decides what to call |
The model, within the host's rules |
The developer's code |
|
Message format |
JSON-RPC 2.0 |
HTTP methods and paths, usually JSON bodies |
|
Transport |
stdio (local) or Streamable HTTP (remote) |
HTTP |
|
Descriptions |
Written for a model to read |
Written for developers |
|
Relationship |
Often wraps an existing API |
The underlying service |
What is an MCP server?
MCP gives AI applications one way to connect to outside systems. Without it, every AI app needs its own plugin format for every service. With it, a service publishes one MCP server and any MCP-compatible app can use it.
Anthropic introduced MCP as an open standard in November 2024. The specification, SDKs and reference servers are developed in the open at modelcontextprotocol.io, and AI apps including Claude, VS Code, Cursor and Windsurf act as MCP hosts.
An MCP server can run on your own machine, like a filesystem or Git server, or as a hosted service, like a SaaS product exposing its API to AI assistants.
How an MCP server works
Hosts, clients and servers
The host is the AI application the user works in. For each server it connects to, the host creates an MCP client that holds one dedicated connection. The server provides the context and capabilities. One host can use many servers at once.
JSON-RPC messages
Clients and servers exchange JSON-RPC 2.0 messages. The client learns which protocol version and capabilities the server supports, lists what it offers (tools/list, resources/list, prompts/list), and calls those features as the conversation needs them.
Transports
stdio: the host launches the server as a local subprocess, and they exchange messages over standard input and output. Typically one client per server.
Streamable HTTP: the server runs at a single HTTP endpoint. The client POSTs each message, and the server replies with JSON or a Server-Sent Events stream. Used for remote servers that serve many clients, with OAuth-based authorization.
The older HTTP+SSE transport from the 2024-11-05 specification is deprecated, though some servers still offer it.
Tools, resources and prompts
Servers offer three kinds of features, each controlled by a different party:
Tools are functions the model can call, such as
search_flights,send_messageorcreate_ticket. Each has a name, a description and a JSON Schema for its inputs. The model decides when to call them, and the spec says a human should be able to deny a call.Resources are read-only data the application can pull into context: file contents, database schemas, documentation pages. Each has a URI.
Prompts are reusable templates the user chooses, such as "summarize this incident", that combine instructions with the right tools and resources.
Rule of thumb: tools are what the model can do, resources are what it can read, and prompts are what the user can start. Give each server only the tools it needs.
What an MCP tool call looks like
Under the hood, a tool call is one JSON-RPC request and one response. This is simplified from the specification's own example. The client sends:
{"jsonrpc": "2.0", "id": 2, "method": "tools/call",
"params": {"name": "get_weather", "arguments": {"location": "New York"}}}
The server replies:
{"jsonrpc": "2.0", "id": 2, "result": {
"content": [{"type": "text", "text": "Current weather in New York: 72°F, partly cloudy"}],
"isError": false}}
The host passes the result back to the model, which uses it in its answer. In practice you build servers with the official SDKs, available for TypeScript, Python and other languages, instead of writing JSON-RPC by hand.
MCP server use cases
Coding assistants: give an IDE agent access to docs, issue trackers, databases or a product's API.
Internal knowledge: let a company assistant search a wiki, CRM or ticket system with the user's own permissions.
Chat and support agents: an AI agent inside a chat app can call MCP tools to look up an order, check a booking or open a ticket mid-conversation, then reply in the thread.
Developer docs: SDK vendors ship read-only docs servers so AI coding tools write integration code from current documentation.
Security pitfalls and limits
An MCP server is code that an AI model drives with real permissions. Treat it like any other integration with access to your systems.
Prompt injection through results. Text returned by a tool or resource (an email, a web page, a ticket) can contain instructions aimed at the model. Treat tool output as untrusted data.
Over-broad tools. A tool that runs any SQL or sends any email hands that power to the model, and to anyone who can steer it. Scope tools narrowly and ask the user to confirm writes.
Untrusted servers. Tool descriptions come from the server, and the spec says clients must treat tool annotations as untrusted unless the server is trusted. Install servers from sources you trust and pin versions.
Local servers run as you. A stdio server is a process on your machine with your permissions. A malicious one can read files or run commands.
Token passthrough and confused deputy. The spec forbids servers from accepting tokens that weren't issued for them, and warns about proxy servers that skip user consent. Server-side request forgery is a risk for servers that fetch URLs.
MCP and AI agents in CometChat
CometChat uses MCP in two places: a docs server for your AI coding tools, and MCP endpoints for the AI agents you run inside chat.
A docs MCP server, and MCP tools for chat agents
The CometChat MCP server at
https://mcp.cometchat.com/mcplets Claude, Cursor, Windsurf, VS Code and other MCP clients search CometChat's docs and pull implementation bundles, such as a React UI Kit quickstart or a multi-tenant chat setup, from inside the conversation. It's read-only and needs no account or API key. Separately, CometChat's Agent Builder lets you add your own MCP server endpoints to an AI agent, so their tools appear next to the native ones and the agent can use them during chat conversations. You can also connect an existing agent built with frameworks such as LangGraph or Mastra.
Frequently asked questions
What is the difference between an MCP server and an API?
An API is built for developers to call from code. An MCP server is built for AI applications: it describes its tools in a way a model can read, and the client discovers them at runtime. Many MCP servers are thin wrappers around an existing API.
What is an MCP server used for?
It lets an AI assistant or agent take actions and read data in other systems, such as searching docs, querying a database, creating a ticket or reading files, without custom integration code in each AI app.
Is MCP only for Claude?
No. Anthropic introduced MCP, but it is an open standard with open SDKs, and many AI applications, including VS Code, Cursor and Windsurf, can connect to MCP servers.
What is the difference between an MCP client and an MCP server?
The client lives inside the AI application (the host) and holds the connection. The server is the separate program that exposes tools, resources and prompts. A host runs one client for each server it connects to.
Are MCP servers safe to use?
They're as safe as the server and its permissions. Install servers from sources you trust, limit what each tool can do, confirm actions that write or send data, and treat tool results as untrusted input that may contain prompt injection.