今日已更新 133 条资讯 | 累计 29586 条内容
关于我们

How to build an MCP server, step by step

Wibo 2026年08月03日 02:02 3 次阅读 来源:Dev.to

Short answer To build an MCP server: install an official MCP SDK, declare your tools with typed inputs, optionally expose resources and prompts, run the server over stdio or HTTP, then connect an MCP client like Claude and test it. A minimal Python server is about ten lines; the work is in choosing what to expose and validating every input. This is the build . For what MCP is, its three primitives, and how it differs from an API, start with what is the Model Context Protocol — this page assumes that and goes straight to code. Prerequisites You need very little to get a server running locally: A language with an official SDK. Python and TypeScript are the most mature; the same protocol is also implemented for other languages. This guide uses the Python SDK (the secondary path most people search for), with notes on where the TypeScript SDK is equivalent. Python 3.10 or newer and uv (recommended) or pip to manage the environment. An MCP client to test against — Claude Desktop, or the MCP Inspector that ships with the SDK. You do not need cloud credentials to build or run the server itself. Conceptually a server exposes three things — tools (model-callable functions), resources (readable data), and prompts (reusable templates) . The steps below add them in that order. Exact SDK signatures evolve, so treat the snippets as the current shape and check the live docs before shipping. Which spec revision this builds against. The code here targets MCP revision 2025-11-25 — the revision the spec's versioning page still names as the current protocol version. Revision 2026-07-28 is published and reworks the wire format substantially. A server built against 2025-11-25 stays conformant today; what the new revision changes for a server author is set out below, so you can build now and plan the move. Step 1: scaffold the server Create a project, install the SDK, and write the smallest server that runs. With uv : uv init weather cd weather uv venv source .venv/bin/activate # Install t

本文内容来源于互联网,版权归原作者所有
查看原文