[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-post-how-to-build-mcp-server-en":3},{"post":4,"faq":34,"faqLdJson":57,"faqLdJsonScript":85,"alternatePaths":86,"recommendations":88,"contentLocale":20},{"authors":5,"custom_excerpt":13,"excerpt":13,"feature_image":14,"featured":15,"id":16,"meta_description":13,"meta_title":17,"og_description":8,"og_image":8,"og_title":8,"primary_author":18,"primary_tag":19,"published_at":22,"reading_time":23,"slug":24,"status":25,"tags":26,"title":17,"twitter_description":8,"twitter_image":8,"twitter_title":31,"updated_at":32,"visibility":21,"lexical":33},[6],{"bio":7,"facebook":8,"instagram":8,"linkedin":8,"location":9,"name":10,"profile_image":11,"slug":12,"tiktok":8,"twitter":8,"website":8,"youtube":8},"As a Senior Editor at Rola IP, Daniel is a true tech enthusiast. In his spare time, he enjoys tinkering with Python scripts, engaging in open-source communities, and exploring core network mechanisms.",null,"Daniel 现任 Rola IP 高级编辑，是一位名副其实的技术爱好者。工作之余，他热衷于钻研 Python 脚本、活跃于开源社区，并不断探索核心网络底层的运行机制。","Daniel Zhao","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FPixPin_2026-08-13_10-47-55.png","daniel","Build an MCP server in Python with the v2 SDK: define a typed tool, run an in-memory test, use Inspector, and choose a secure transport for deployment.","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F-------19.webp",false,"6a8fba5a4956c90001bedf3d","How to Build an MCP Server with Python: v2 Tutorial",{"bio":7,"facebook":8,"instagram":8,"linkedin":8,"location":9,"name":10,"profile_image":11,"slug":12,"tiktok":8,"twitter":8,"website":8,"youtube":8},{"description":8,"feature_image":8,"name":20,"slug":20,"visibility":21},"en","public","2026-08-27T04:24:30.000Z",7,"how-to-build-mcp-server","published",[27,28],{"description":8,"feature_image":8,"name":20,"slug":20,"visibility":21},{"description":8,"feature_image":8,"name":29,"slug":30,"visibility":21},"教程","guides","how to build mcp server","2026-10-10T03:34:59.000Z","{\"root\":{\"children\":[{\"type\":\"markdown\",\"version\":1,\"markdown\":\"## TL;DR\\n\\nTo build an MCP server, install the official v2 Python SDK, create an `MCPServer` instance, decorate a typed Python function with `@mcp.tool()`, then test the tool before connecting it to an MCP host. Start with `stdio` for a local server; use Streamable HTTP only when you need a deployed endpoint and have added authentication, authorization, logging, and network controls.\\n\\n![mcp-server-architecture](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F01-mcp-server-architecture.webp)\\n\\n## What an MCP Server Does\\n\\nMCP is a protocol for connecting an AI application to external context and capabilities. A server can expose three core primitives:\\n\\n| Primitive | Use it for | First-server advice |\\n|---|---|---|\\n| Tool | An action or calculation with inputs | Start here; make input and output types explicit. |\\n| Resource | Readable context identified by a URI | Add it for stable reference data. |\\n| Prompt | A reusable message template | Add it only when the client benefits from a guided interaction. |\\n\\nThe protocol is not a permission system. A tool can still do harm if it accepts arbitrary shell commands, unrestricted URLs, or over-broad credentials. Design the capability boundary before the function body. For example, a `get_project_note(topic)` tool is easier to review than a generic `run_any_request(url)` tool.\\n\\nThe official Python SDK documents `stdio` as the default local transport and Streamable HTTP as the transport for an HTTP deployment. It also notes that SSE is retained for compatibility but is not the recommended choice for new servers. See the [official SDK running guide](https:\u002F\u002Fpy.sdk.modelcontextprotocol.io\u002Frun\u002F) for current transport behavior.\\n\\n## Prerequisites and Verified v2 Environment\\n\\nThis walkthrough targets Python 3.10+ on macOS, Linux, or Windows PowerShell. The commands use a virtual environment so the project dependency stays isolated. The Inspector flow also requires Node.js and `npx` on your `PATH`.\\n\\n**Test evidence (2026-08-26):** the server and in-memory `pytest` test in this tutorial were run on Windows with Python 3.12.13, `mcp==2.1.1`, and `pytest==9.1.1`; the result was `1 passed`.\\n\\n| Requirement | Current choice | Why it matters |\\n|---|---|---|\\n| Python | 3.10 or later | This is the v2 SDK's documented minimum. |\\n| SDK | `mcp[cli]==2.1.1` | Pins the current stable v2 line used by this tutorial. |\\n| Transport | `stdio` | Lowest-friction local integration. |\\n| Test target | In-memory client | Verifies the tool without opening a port. |\\n| Inspector | Node.js plus `npx` | Required by `mcp dev` to launch the Inspector. |\\n\\nThe official documentation describes v2 as the current stable release line. v1 remains a maintenance line for projects that are not ready to migrate. This tutorial deliberately uses v2 end to end: its imports, client test, Inspector command, and documentation links all target the same major version. [The v2 installation guide](https:\u002F\u002Fpy.sdk.modelcontextprotocol.io\u002Fget-started\u002Finstallation\u002F) is the source of truth when you update the pin.\\n\\n| Decision | v2 tutorial path | v1 maintenance path |\\n|---|---|---|\\n| Server import | `from mcp.server import MCPServer` | Use the v1.x branch documentation and APIs. |\\n| Test import | `from mcp import Client` | Do not copy v2 test imports into a v1 project. |\\n| Documentation | `py.sdk.modelcontextprotocol.io` current docs | Versioned v1.x documentation only. |\\n| Recommendation for a new project | Use v2 | Use only when migration is not yet feasible. |\\n\\nCreate the environment:\\n\\n```powershell\\npy -3.11 -m venv .venv\\n.\\\\.venv\\\\Scripts\\\\Activate.ps1\\npython -m pip install --upgrade pip\\npip install \\\"mcp[cli]==2.1.1\\\" pytest\\n```\\n\\nFor macOS or Linux, activate with `source .venv\u002Fbin\u002Factivate`. Confirm the installed package before copying a version-sensitive snippet:\\n\\n```bash\\nmcp version\\n```\\n\\nIf `mcp version` is unavailable in your environment, use `python -c \\\"from importlib.metadata import version; print(version('mcp'))\\\"` to confirm the installed package version.\\n\\n![mcp-v2-install-output](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F04-mcp-v2-install-output.webp)\\n\\n## Step 1: Define a Narrow, Typed Tool\\n\\nCreate `server.py`. The tool below reads from an in-memory allowlist so it has no credentials, external requests, or file-system side effects. A real implementation can replace the dictionary with an approved service adapter after you define authorization and audit requirements.\\n\\n```python\\nfrom mcp.server import MCPServer\\n\\nmcp = MCPServer(\\\"Project Notes\\\")\\n\\nNOTES = {\\n    \\\"release\\\": \\\"Release checklist: tests, changelog, and rollback owner.\\\",\\n    \\\"security\\\": \\\"Security checklist: least privilege, secret rotation, and audit logs.\\\",\\n}\\n\\n\\n@mcp.tool()\\ndef get_project_note(topic: str) -> dict[str, str]:\\n    \\\"\\\"\\\"Return an approved project note for a known topic.\\\"\\\"\\\"\\n    key = topic.strip().lower()\\n    if key not in NOTES:\\n        return {\\n            \\\"status\\\": \\\"not_found\\\",\\n            \\\"message\\\": \\\"Use one of: release, security.\\\",\\n        }\\n    return {\\\"status\\\": \\\"ok\\\", \\\"topic\\\": key, \\\"note\\\": NOTES[key]}\\n\\n\\nif __name__ == \\\"__main__\\\":\\n    mcp.run()\\n```\\n\\nWhy this design works:\\n\\n- The function signature creates a clear input schema for the client.\\n- The return value is structured JSON, not an ambiguous text blob.\\n- The server limits accepted topics instead of forwarding arbitrary input to another system.\\n- `mcp.run()` defaults to `stdio`, which suits a local host that launches the process.\\n\\nWhen people ask *how to build an mcp server*, the code is only half the task. The other half is deciding what the tool is allowed to do. Keep credentials on the server side, never in a tool description or response, and map each tool to a least-privilege service account.\\n\\n![build-mcp-server-workflow](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F02-build-mcp-server-workflow-1.webp)\\n\\n## Step 2: Test the Server Before Connecting a Host\\n\\nThe SDK documentation recommends an in-memory client for server tests. This is valuable because it verifies the registered tool and structured response without subprocess configuration, ports, or a desktop host.\\n\\nCreate `test_server.py` next to `server.py`:\\n\\n```python\\nimport pytest\\nfrom mcp import Client\\n\\nfrom server import mcp\\n\\n\\n@pytest.mark.anyio\\nasync def test_get_project_note() -> None:\\n    async with Client(mcp, raise_exceptions=True) as client:\\n        result = await client.call_tool(\\\"get_project_note\\\", {\\\"topic\\\": \\\"release\\\"})\\n\\n    assert result.structured_content == {\\n        \\\"status\\\": \\\"ok\\\",\\n        \\\"topic\\\": \\\"release\\\",\\n        \\\"note\\\": \\\"Release checklist: tests, changelog, and rollback owner.\\\",\\n    }\\n```\\n\\nInstall the test dependency and run it:\\n\\n```bash\\npip install pytest\\npytest -q\\n```\\n\\nExpected output:\\n\\n```text\\n1 passed\\n```\\n\\n![mcp-v2-pytest-output](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F05-mcp-v2-pytest-output.webp)\\n\\nThis test shape follows the v2 SDK's current getting-started guidance: `Client(mcp)` connects directly to the server object, so you validate behavior before involving a transport. Keep the SDK pin, imports, and [official v2 testing documentation](https:\u002F\u002Fpy.sdk.modelcontextprotocol.io\u002Fget-started\u002Ftesting\u002F) aligned whenever you update the project.\\n\\n## Step 3: Run Locally and Inspect It\\n\\nFor manual development, use the Inspector instead of running a `stdio` server alone. The Inspector launches the server as a subprocess and connects over `stdio`; it requires Node.js and `npx` on your `PATH`.\\n\\n```bash\\n# With uv installed:\\nuv run mcp dev server.py\\n\\n# Or, after installing the [cli] extra into the active virtual environment:\\nmcp dev server.py\\n```\\n\\nOpen the URL printed by the Inspector, select **Tools**, call `get_project_note` with `release`, and verify that the structured result contains `status: ok`. Running `python server.py` directly is useful only to confirm that a `stdio` server stays alive awaiting client input; it does not open the Inspector. Keep standard output reserved for the protocol. Send diagnostics to standard error or the SDK logging facilities.\\n\\nUse a tool name, description, input type, and return type that explain the permission boundary. A host should be able to tell what `get_project_note` can retrieve without executing it. Avoid a catch-all tool named `query`, `fetch`, or `execute` unless its allowlists, ownership checks, and rate limits are independently enforced.\\n\\n## Step 4: Choose `stdio` or Streamable HTTP\\n\\nChoose the transport from the deployment boundary, not from convenience alone.\\n\\n| Situation | Better starting choice | Extra controls |\\n|---|---|---|\\n| One developer and a local desktop host | `stdio` | Process path review; no secrets in config. |\\n| Internal service behind a gateway | Streamable HTTP | TLS, token validation, authorization, logs, request limits. |\\n| Existing ASGI application | Mount a Streamable HTTP server | Route isolation, lifecycle tests, and observability. |\\n| Older client that only supports SSE | Compatibility-only SSE | Plan a migration; do not choose it for a new build. |\\n\\nFor a deployed server, treat MCP as an application API. Authenticate the caller, authorize each tool and object, validate inputs, limit output size, record audit events, and rotate credentials. The SDK's [authentication section](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fpython-sdk#authentication) describes resource-server support and token verification concepts, but it is still your responsibility to implement a verifier and an access policy suitable for your environment.\\n\\n## Adding an Approved External Data Tool\\n\\nDo not make a first MCP server scrape arbitrary sites. If you later add a tool that calls an external API or reads public web content, document the data owner, authorized purpose, input allowlist, timeout, and stop conditions. A 401, 403, or 429 is a signal to stop and review access, not something to work around.\\n\\nFor permitted location-sensitive QA or public-data workflows, you might route an approved outbound request through a controlled network configuration. Review [proxy networks](https:\u002F\u002Fdoc.rola-ip.co\u002Fguide\u002Fproxy-networks\u002F) and [Python proxy integration](https:\u002F\u002Fdoc.rola-ip.co\u002Fguide\u002Fintegration\u002Fpython.html) before implementation, and keep the proxy credential outside model-visible prompts. If a project genuinely requires regional verification, a [residential proxy](https:\u002F\u002Frola-ip.co\u002Fresidential-ip\u002F) can be evaluated for authorized use under the target service's terms; it is not a bypass mechanism for access controls or rate limits.\\n\\n## Common Failures and How to Verify Them\\n\\n| Symptom | Likely cause | How to verify | Safe fix |\\n|---|---|---|---|\\n| Tool is missing | Decorator or import was not loaded | Inspect the tool list in your test or inspector | Import the module once and use `@mcp.tool()`. |\\n| Input is rejected | Schema and client arguments differ | Compare the function type hint with the call payload | Use explicit scalar or model fields; add a failing test. |\\n| Client disconnects | `stdio` output was polluted or process exited | Check stderr and remove stdout prints | Use logging to stderr; run the server directly once. |\\n| HTTP call times out | Route, gateway, or upstream dependency is unhealthy | Check server logs and a bounded health endpoint | Set timeouts, return a clear error, and retry only when authorized. |\\n| Tool returns too much data | Output is unbounded | Measure response size in a test | Paginate, summarize, or return a resource URI. |\\n\\n![mcp-server-troubleshooting](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F03-mcp-server-troubleshooting.webp)\\n\\n## Production Checklist\\n\\nBefore exposing the server beyond your workstation, answer these questions in writing:\\n\\n1. Which people, clients, and service accounts may call each tool?\\n2. Which records, domains, commands, or query parameters are allowed?\\n3. Does each external action have a timeout, output limit, and audit event?\\n4. Can the model cause a side effect without an explicit user confirmation?\\n5. Can you revoke a credential or disable a tool without redeploying the client?\\n\\nRola IP can fit naturally into a server that supports approved data workflows, but it should remain an implementation detail guarded by configuration and policy. Start with the [Rola IP documentation](https:\u002F\u002Fdoc.rola-ip.co\u002F) when a controlled, authorized outbound connection is actually part of the tool's job.\\n\"},{\"children\":[],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"paragraph\",\"version\":1}],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}",{"items":35,"inline":15},[36,39,42,45,48,51,54],{"title":37,"desc":38},"Is MCPServer the same as the MCP protocol?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">No. MCP is the protocol; \u003C\u002Fspan>\u003Ccode spellcheck=\"false\" style=\"white-space: pre-wrap;\">\u003Cspan>MCPServer\u003C\u002Fspan>\u003C\u002Fcode>\u003Cspan style=\"white-space: pre-wrap;\"> is the v2 Python SDK class that implements server behavior for you. It registers typed tools, resources, and prompts, but it does not define your permissions or deployment policy. Your application still needs explicit capability boundaries, tests, and access controls. Use lower-level APIs only when you have a concrete protocol requirement that \u003C\u002Fspan>\u003Ccode spellcheck=\"false\" style=\"white-space: pre-wrap;\">\u003Cspan>MCPServer\u003C\u002Fspan>\u003C\u002Fcode>\u003Cspan style=\"white-space: pre-wrap;\"> cannot meet.\u003C\u002Fspan>\u003C\u002Fp>",{"title":40,"desc":41},"Do I need Streamable HTTP for my first MCP server?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">No. Use \u003C\u002Fspan>\u003Ccode spellcheck=\"false\" style=\"white-space: pre-wrap;\">\u003Cspan>stdio\u003C\u002Fspan>\u003C\u002Fcode>\u003Cspan style=\"white-space: pre-wrap;\"> first when a local host can launch the server as a subprocess. It reduces deployment surface area and avoids running a network listener during early development. Choose Streamable HTTP only when the server must be independently deployed or shared through a controlled network path. At that point, add TLS, token verification, per-tool authorization, request limits, logs, and a deployment test; transport selection does not remove those requirements.\u003C\u002Fspan>\u003C\u002Fp>",{"title":43,"desc":44},"How do I validate MCP tool inputs?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Validate at the tool boundary. Use precise Python type hints for simple fields, and use explicit models for nested inputs. Then add tests for valid input, missing input, unsupported values, and oversized requests. Do not rely on the model's natural-language instruction as validation. Your tool should reject data that falls outside its documented contract before it reaches a database, shell, network client, or privileged API.\u003C\u002Fspan>\u003C\u002Fp>",{"title":46,"desc":47},"Can an MCP tool call any URL a user provides?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">It should not by default. Arbitrary URL tools can create SSRF, data-exfiltration, and policy problems, especially when credentials or internal networks are reachable. Prefer a domain allowlist, fixed API base URL, path validation, a short timeout, response-size limits, and no redirects unless they are necessary and controlled. For a public-web workflow, honor the target's permissions, terms, and rate limits. Treat access denials and throttling as stop signals.\u003C\u002Fspan>\u003C\u002Fp>",{"title":49,"desc":50},"Why does my stdio server disconnect immediately?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Unexpected stdout is a common cause. In a \u003C\u002Fspan>\u003Ccode spellcheck=\"false\" style=\"white-space: pre-wrap;\">\u003Cspan>stdio\u003C\u002Fspan>\u003C\u002Fcode>\u003Cspan style=\"white-space: pre-wrap;\"> transport, stdout carries protocol messages, so diagnostic prints can corrupt the conversation. Move diagnostics to stderr or the SDK logging mechanism, run \u003C\u002Fspan>\u003Ccode spellcheck=\"false\" style=\"white-space: pre-wrap;\">\u003Cspan>python server.py\u003C\u002Fspan>\u003C\u002Fcode>\u003Cspan style=\"white-space: pre-wrap;\"> directly to inspect startup errors, and verify the host's command path and virtual environment. Also check that the process remains alive after import; a missing dependency or an exception in module initialization can look like a transport failure.\u003C\u002Fspan>\u003C\u002Fp>",{"title":52,"desc":53},"How should I handle secrets in an MCP server?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Keep secrets outside prompts, tool descriptions, and tool return values. Load them from your deployment's approved secret store or environment configuration, scope them to the smallest service account possible, and make sure logs redact them. A model should never be able to request a secret back as normal tool output. Rotate credentials regularly, limit access by environment, and test that an error path does not include headers, tokens, connection strings, or internal URLs.\u003C\u002Fspan>\u003C\u002Fp>",{"title":55,"desc":56},"Do MCP tools need human confirmation for side effects?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Usually, yes. A tool that sends a message, changes a record, deploys code, spends money, or calls an irreversible API should have a clear confirmation workflow and a narrow authorization policy. Return a dry-run or preview whenever practical, then require an explicit user-approved action with enough context to understand the effect. Do not treat an earlier vague request as authorization for a later high-impact operation.\u003C\u002Fspan>\u003C\u002Fp>",{"@context":58,"@type":59,"@id":60,"mainEntity":61},"https:\u002F\u002Fschema.org","FAQPage","https:\u002F\u002Frola-ip.co\u002Fblog\u002Fhow-to-build-mcp-server\u002F#faq",[62,67,70,73,76,79,82],{"@type":63,"name":37,"acceptedAnswer":64},"Question",{"@type":65,"text":66},"Answer","No. MCP is the protocol; MCPServer is the v2 Python SDK class that implements server behavior for you. It registers typed tools, resources, and prompts, but it does not define your permissions or deployment policy. Your application still needs explicit capability boundaries, tests, and access controls. Use lower-level APIs only when you have a concrete protocol requirement that MCPServer cannot meet.",{"@type":63,"name":40,"acceptedAnswer":68},{"@type":65,"text":69},"No. Use stdio first when a local host can launch the server as a subprocess. It reduces deployment surface area and avoids running a network listener during early development. Choose Streamable HTTP only when the server must be independently deployed or shared through a controlled network path. At that point, add TLS, token verification, per-tool authorization, request limits, logs, and a deployment test; transport selection does not remove those requirements.",{"@type":63,"name":43,"acceptedAnswer":71},{"@type":65,"text":72},"Validate at the tool boundary. Use precise Python type hints for simple fields, and use explicit models for nested inputs. Then add tests for valid input, missing input, unsupported values, and oversized requests. Do not rely on the model's natural-language instruction as validation. Your tool should reject data that falls outside its documented contract before it reaches a database, shell, network client, or privileged API.",{"@type":63,"name":46,"acceptedAnswer":74},{"@type":65,"text":75},"It should not by default. Arbitrary URL tools can create SSRF, data-exfiltration, and policy problems, especially when credentials or internal networks are reachable. Prefer a domain allowlist, fixed API base URL, path validation, a short timeout, response-size limits, and no redirects unless they are necessary and controlled. For a public-web workflow, honor the target's permissions, terms, and rate limits. Treat access denials and throttling as stop signals.",{"@type":63,"name":49,"acceptedAnswer":77},{"@type":65,"text":78},"Unexpected stdout is a common cause. In a stdio transport, stdout carries protocol messages, so diagnostic prints can corrupt the conversation. Move diagnostics to stderr or the SDK logging mechanism, run python server.py directly to inspect startup errors, and verify the host's command path and virtual environment. Also check that the process remains alive after import; a missing dependency or an exception in module initialization can look like a transport failure.",{"@type":63,"name":52,"acceptedAnswer":80},{"@type":65,"text":81},"Keep secrets outside prompts, tool descriptions, and tool return values. Load them from your deployment's approved secret store or environment configuration, scope them to the smallest service account possible, and make sure logs redact them. A model should never be able to request a secret back as normal tool output. Rotate credentials regularly, limit access by environment, and test that an error path does not include headers, tokens, connection strings, or internal URLs.",{"@type":63,"name":55,"acceptedAnswer":83},{"@type":65,"text":84},"Usually, yes. A tool that sends a message, changes a record, deploys code, spends money, or calls an irreversible API should have a clear confirmation workflow and a narrow authorization policy. Return a dry-run or preview whenever practical, then require an explicit user-approved action with enough context to understand the effect. Do not treat an earlier vague request as authorization for a later high-impact operation.","{\"@context\":\"https:\u002F\u002Fschema.org\",\"@type\":\"FAQPage\",\"@id\":\"https:\u002F\u002Frola-ip.co\u002Fblog\u002Fhow-to-build-mcp-server\u002F#faq\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"Is MCPServer the same as the MCP protocol?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. MCP is the protocol; MCPServer is the v2 Python SDK class that implements server behavior for you. It registers typed tools, resources, and prompts, but it does not define your permissions or deployment policy. Your application still needs explicit capability boundaries, tests, and access controls. Use lower-level APIs only when you have a concrete protocol requirement that MCPServer cannot meet.\"}},{\"@type\":\"Question\",\"name\":\"Do I need Streamable HTTP for my first MCP server?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. Use stdio first when a local host can launch the server as a subprocess. It reduces deployment surface area and avoids running a network listener during early development. Choose Streamable HTTP only when the server must be independently deployed or shared through a controlled network path. At that point, add TLS, token verification, per-tool authorization, request limits, logs, and a deployment test; transport selection does not remove those requirements.\"}},{\"@type\":\"Question\",\"name\":\"How do I validate MCP tool inputs?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Validate at the tool boundary. Use precise Python type hints for simple fields, and use explicit models for nested inputs. Then add tests for valid input, missing input, unsupported values, and oversized requests. Do not rely on the model's natural-language instruction as validation. Your tool should reject data that falls outside its documented contract before it reaches a database, shell, network client, or privileged API.\"}},{\"@type\":\"Question\",\"name\":\"Can an MCP tool call any URL a user provides?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It should not by default. Arbitrary URL tools can create SSRF, data-exfiltration, and policy problems, especially when credentials or internal networks are reachable. Prefer a domain allowlist, fixed API base URL, path validation, a short timeout, response-size limits, and no redirects unless they are necessary and controlled. For a public-web workflow, honor the target's permissions, terms, and rate limits. Treat access denials and throttling as stop signals.\"}},{\"@type\":\"Question\",\"name\":\"Why does my stdio server disconnect immediately?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Unexpected stdout is a common cause. In a stdio transport, stdout carries protocol messages, so diagnostic prints can corrupt the conversation. Move diagnostics to stderr or the SDK logging mechanism, run python server.py directly to inspect startup errors, and verify the host's command path and virtual environment. Also check that the process remains alive after import; a missing dependency or an exception in module initialization can look like a transport failure.\"}},{\"@type\":\"Question\",\"name\":\"How should I handle secrets in an MCP server?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Keep secrets outside prompts, tool descriptions, and tool return values. Load them from your deployment's approved secret store or environment configuration, scope them to the smallest service account possible, and make sure logs redact them. A model should never be able to request a secret back as normal tool output. Rotate credentials regularly, limit access by environment, and test that an error path does not include headers, tokens, connection strings, or internal URLs.\"}},{\"@type\":\"Question\",\"name\":\"Do MCP tools need human confirmation for side effects?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Usually, yes. A tool that sends a message, changes a record, deploys code, spends money, or calls an irreversible API should have a clear confirmation workflow and a narrow authorization policy. Return a dry-run or preview whenever practical, then require an explicit user-approved action with enough context to understand the effect. Do not treat an earlier vague request as authorization for a later high-impact operation.\"}}]}",[87],"\u002Fblog\u002Fhow-to-build-mcp-server\u002F",{"prev":89,"next":102,"related":113,"popular":147,"latest":211},{"id":90,"title":91,"slug":92,"feature_image":93,"published_at":94,"twitter_title":95,"primary_tag":96,"tags":97},"6a8fb4b84956c90001bedf1f","Best Proxies for Scraping: 6 Providers Compared (2026)","best-proxies-for-scraping","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FBest-Proxies-for-Scraping-article-cover-image.webp","2026-08-27T04:33:04.000Z","Proxies for Scraping",{"name":20,"slug":20},[98,99],{"name":20,"slug":20,"visibility":21},{"name":100,"slug":101,"visibility":21},"应用场景","use-cases",{"id":103,"title":104,"slug":105,"feature_image":106,"published_at":107,"twitter_title":108,"primary_tag":109,"tags":110},"6a8fb23b4956c90001bedeec","How to Run a .py File: Terminal and VS Code Steps","how-to-run-a-py-file","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F-------18.webp","2026-08-27T03:52:03.000Z","running a py file",{"name":20,"slug":20},[111,112],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},[114,125,136],{"id":115,"title":116,"slug":117,"feature_image":118,"published_at":119,"twitter_title":120,"primary_tag":121,"tags":122},"6b0d3e4b92ab700001dc0a73","Scrape Indeed Jobs with Python: Extract Job Fields and Export to CSV","scrape-indeed-jobs","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FScrape-Indeed-Jobs.webp","2026-11-30T09:37:05.000Z","indeed job scraper",{"name":20,"slug":20},[123,124],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":126,"title":127,"slug":128,"feature_image":129,"published_at":130,"twitter_title":131,"primary_tag":132,"tags":133},"6b0d2bcb92ab700001dc0a12","Node.js HTTP Proxy Tutorial: Send HTTPS Requests with Rola IP and Verify the Exit IP","node-js-http-proxy","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FNode.js-HTTP-Proxy-Tutorial_-Send-HTTPS-Requests-with-Rola-IP-and-Verify-the-Exit-IP.webp","2026-11-30T07:58:57.000Z","node js http proxy",{"name":20,"slug":20},[134,135],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":137,"title":138,"slug":139,"feature_image":140,"published_at":141,"twitter_title":142,"primary_tag":143,"tags":144},"6b09485d92ab700001dc0953","How to Set Up Chrome DevTools MCP for Multi-Region Geo-Testing with Residential Proxies","chrome-devtools-mcp-proxy-setup","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002Fchrome-devtools-mcp-proxy-setup.webp","2026-11-27T09:22:44.000Z","chrome-devtools-mcp proxy setup",{"name":20,"slug":20},[145,146],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},[148,163,175,187,199],{"id":149,"title":150,"slug":151,"feature_image":152,"published_at":153,"twitter_title":154,"primary_tag":155,"tags":156},"6aa1292f4956c90001bef44e","ProxySite.com Review (2026): Is It Safe? 5 Best Alternatives","proxysite-review-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002FProxySite-Review-and--Alternatives-article-cover-image.webp","2026-09-09T10:16:50.000Z","proxysite",{"name":20,"slug":20},[157,158,161],{"name":20,"slug":20,"visibility":21},{"name":159,"slug":160,"visibility":21},"对比选型","comparisons",{"name":162,"slug":162,"visibility":21},"hot",{"id":164,"title":165,"slug":166,"feature_image":167,"published_at":168,"twitter_title":169,"primary_tag":170,"tags":171},"6a978f9a4956c90001bee8bb","BlockAway Alternatives: 6 Best Options (2026)","blockaway-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002FBlockAway-Alternatives-article-cover-image.webp","2026-09-02T03:14:08.000Z","blockaway alternative",{"name":20,"slug":20},[172,173,174],{"name":20,"slug":20,"visibility":21},{"name":159,"slug":160,"visibility":21},{"name":162,"slug":162,"visibility":21},{"id":176,"title":177,"slug":178,"feature_image":179,"published_at":180,"twitter_title":181,"primary_tag":182,"tags":183},"6a912ce84956c90001bee35d","HTTPX vs Requests vs aiohttp: Features, Performance, and Python Use Cases","httpx-vs-requests-vs-aiohttp","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FHTTPX-vs-Requests-vs-aiohttp-article-cover-image.webp","2026-08-28T07:27:34.000Z","httpx vs requests",{"name":20,"slug":20},[184,185,186],{"name":20,"slug":20,"visibility":21},{"name":159,"slug":160,"visibility":21},{"name":162,"slug":162,"visibility":21},{"id":188,"title":189,"slug":190,"feature_image":191,"published_at":192,"twitter_title":193,"primary_tag":194,"tags":195},"6a90fcea4956c90001bee256","8 Best Germany Proxies in 2026: Provider Comparison","best-germany-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FBest-Germany-Proxies-article-cover-image.webp","2026-08-28T03:40:55.000Z","germany proxy",{"name":20,"slug":20},[196,197,198],{"name":20,"slug":20,"visibility":21},{"name":159,"slug":160,"visibility":21},{"name":162,"slug":162,"visibility":21},{"id":200,"title":201,"slug":202,"feature_image":203,"published_at":204,"twitter_title":205,"primary_tag":206,"tags":207},"6a8e92664956c90001beddc2","Bing Rank Tracker: Reliable Local SERP Monitoring Guide","bing-rank-tracker","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F-------16.webp","2026-08-26T07:42:04.000Z","bing rank checker",{"name":20,"slug":20},[208,209,210],{"name":20,"slug":20,"visibility":21},{"name":100,"slug":101,"visibility":21},{"name":162,"slug":162,"visibility":21},[212,225,236,247,258],{"id":213,"title":214,"slug":215,"feature_image":216,"published_at":217,"twitter_title":218,"primary_tag":219,"tags":220},"6b0946f492ab700001dc0920","Best Rotating Proxies in 2026 7 Rotating Proxy Providers Compared","best-rotating-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FBest-Rotating-Proxies-in-2026-7-Rotating-Proxy-Providers-Compared.webp","2026-11-27T09:07:09.000Z","best rotating proxies",{"name":20,"slug":20},[221,222],{"name":20,"slug":20,"visibility":21},{"name":223,"slug":224,"visibility":21},"排行榜","top-picks",{"id":226,"title":227,"slug":228,"feature_image":229,"published_at":230,"twitter_title":231,"primary_tag":232,"tags":233},"6b07a50492ab700001dc0603","How to Configure an NGINX Docker Reverse Proxy with Rola IP Egress","nginx-docker-reverse-proxy","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FHow-to-Configure-an-NGINX-Docker-Reverse-Proxy-with-Rola-IP-Egress-1.webp","2026-11-26T03:21:51.000Z","nginx docker reverse proxy",{"name":20,"slug":20},[234,235],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":237,"title":238,"slug":239,"feature_image":240,"published_at":241,"twitter_title":242,"primary_tag":243,"tags":244},"6b079b8692ab700001dc05ce","Android Proxy Settings for Mobile Network: The No-Root Guide (2026)","android-proxy-settings-mobile-network","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FAndroid-Proxy-Settings-for-Mobile-Network_-The-No-Root-Guide--2026-.webp","2026-11-26T03:10:40.000Z","android proxy settings mobile network",{"name":20,"slug":20},[245,246],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":248,"title":249,"slug":250,"feature_image":251,"published_at":252,"twitter_title":253,"primary_tag":254,"tags":255},"6b0655a092ab700001dc0440","Rammerhead Proxy: Setup, HTTP Upstreams and Alternatives","rammerhead-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002Frammerhead-alternatives.webp","2026-11-25T03:59:48.000Z","Rammerhead Proxy",{"name":20,"slug":20},[256,257],{"name":20,"slug":20,"visibility":21},{"name":159,"slug":160,"visibility":21},{"id":259,"title":260,"slug":261,"feature_image":262,"published_at":263,"twitter_title":264,"primary_tag":265,"tags":266},"6b05417f92ab700001dc034d","ProxyEmpire Review (2026): Our Best Alternative for Predictable Bulk Residential Use","proxyempire-review","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FProxyEmpire-Review--2026-_-Our-Best-Alternative-for-Predictable-Bulk-Residential-Use.webp","2026-11-24T08:12:53.000Z","proxyempire review",{"name":20,"slug":20},[267,268],{"name":20,"slug":20,"visibility":21},{"name":159,"slug":160,"visibility":21}]