What is an MCP server, and how do you build one?
An MCP server is a program that exposes capabilities, mainly tools, resources and prompts, to AI applications using the Model Context Protocol. It usually wraps something that already exists, such as a database, a SaaS API or your file system, so that any MCP-compatible assistant or agent can use it without custom integration code.
An MCP server is an adapter. On one side it speaks the Model Context Protocol; on the other it talks to whatever system you want an AI application to reach.
What does an MCP server do?
An MCP server answers two kinds of requests from an AI application's MCP client: "what can you do?" and "do this". When a client connects, the server lists its capabilities, each with a name, a description written for the model and an input schema. When the model decides to use one, the client sends a request and the server runs it against the underlying system, then returns the result. The Model Context Protocol page covers how hosts, clients and servers fit together.
What are examples of MCP servers?
| Server | What it wraps | Typical tools or resources |
|---|---|---|
| File system | A folder on your machine | Read, write and search files within allowed directories |
| Git or GitHub | Repositories and pull requests | Search code, read issues, open a pull request |
| Database (Postgres, SQLite) | A database connection | Inspect the schema, run read-only queries |
| Browser automation | A headless browser | Open a page, click, take a screenshot |
| Team tools (Slack, Linear, Notion) | A SaaS API | Search messages, create a ticket, read a page |
| Internal service | Your company's own API | Look up a customer, check an order status |
The official MCP servers repository on GitHub lists reference implementations, and most major SaaS companies now publish their own official servers.
What is the difference between a local and a remote MCP server?
A local server runs on the user's machine as a subprocess of the AI application and talks over standard input and output (stdio). A remote server runs somewhere on the network and is reached over HTTP with the Streamable HTTP transport.
| Aspect | Local (stdio) | Remote (Streamable HTTP) |
|---|---|---|
| Where it runs | On the user's computer | On a server or cloud service |
| Good for | Personal tools, files, local development | Shared team tools and SaaS integrations |
| Authentication | Uses the local user's own access | OAuth-based authorisation defined by the spec |
| Setup for users | Install and configure per machine | Add a URL and sign in |
How do you build a simple MCP server?
Official SDKs exist for Python, TypeScript and several other languages. With the Python SDK, a minimal server with one tool looks like this:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("orders")
@mcp.tool()
def get_order_status(order_id: str) -> str:
"""Look up the delivery status of an order by its ID, like 'ORD-1042'.
Returns the status and expected delivery date."""
order = ORDERS_DB.get(order_id) # your real lookup goes here
if order is None:
return f"No order found with ID {order_id}."
return f"{order_id}: {order['status']}, expected {order['eta']}."
if __name__ == "__main__":
mcp.run() # stdio transport by default
The SDK turns the function's name, type hints and docstring into the tool definition the model sees, so the docstring is effectively your tool description. You then add the server to a host's configuration, and test it with the MCP Inspector, a developer tool that lets you call your server's tools by hand. The free guide's chapter "Building Your First Server" walks through a complete example.
How do you design a good MCP server?
The quality of a server is mostly the quality of its tools: how clear they are to the model, and how safe they are to call.
- Do: Design tools around user tasks, like find_customer_orders, not around raw API endpoints
- Do: Write descriptions that say when to use each tool and what it returns
- Do: Return short, readable results and error messages that tell the model what to try next
- Do: Make read-only tools the default, and put write actions in separate, clearly named tools
- Do: Validate every argument and enforce permissions in the server, not in the prompt
- Avoid: Mirror every endpoint of an API as a tool; too many similar tools confuse the model
- Avoid: Return raw, very large payloads that fill the context window
- Avoid: Put credentials in tool arguments where the model can see them
What security risks do MCP servers have?
An MCP server acts with whatever access you give it, and the model decides when to call it, so treat it like any other privileged integration. Data a server returns, such as an email body or a web page, can contain prompt injection that tries to steer the model into calling other tools. Use least-privilege credentials, require confirmation for destructive actions, log tool calls, and only install third-party servers you trust.
Frequently asked questions
What language can I write an MCP server in?
Official SDKs are available for Python, TypeScript, Java, Kotlin, C#, Go and other languages. Any language can implement the protocol, since it is JSON-RPC messages over stdio or HTTP.
Is an MCP server the same as an API?
No. An MCP server often wraps an API, but it presents that API in a standard form that AI applications can discover and use automatically, with descriptions written for a model.
How do I test an MCP server?
Use the MCP Inspector to connect to your server, list its tools and call them with test arguments. Then connect it to a real host and check that the model chooses the right tools for realistic requests.
Can one AI app use several MCP servers at once?
Yes. A host runs one MCP client per server and can connect to many servers at the same time, offering all of their tools to the model together.
Last checked for accuracy on . Written by the solidcoder team.