一键导入
mcp-development
// Build Model Context Protocol (MCP) servers with tools, resources, and prompts. Use when creating MCP servers, choosing stdio vs HTTP transport, debugging MCP behavior, or implementing MCP patterns in Python or TypeScript.
// Build Model Context Protocol (MCP) servers with tools, resources, and prompts. Use when creating MCP servers, choosing stdio vs HTTP transport, debugging MCP behavior, or implementing MCP patterns in Python or TypeScript.
Run the correct validation checks for changed files in this repository (Bun frontend checks, uv Python checks, and workflow or guidance verification).
Bootstrap Copilot guidance for any repository by creating or updating `.github/workflows/copilot-setup-steps.yml`, focused lint/check/test workflows, `.github/instructions/*.instructions.md`, and `.github/skills/*/SKILL.md`. Use when asked to initialize Copilot guidance, scaffold repo instructions or skills, create or update `copilot-setup-steps`, or add Copilot-facing validation workflows.
A comprehensive guide for GitHub Copilot to craft immersive, high-performance web experiences with advanced motion, typography, and architectural craftsmanship.
Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.
| name | mcp-development |
| description | Build Model Context Protocol (MCP) servers with tools, resources, and prompts. Use when creating MCP servers, choosing stdio vs HTTP transport, debugging MCP behavior, or implementing MCP patterns in Python or TypeScript. |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep |
Build and debug Model Context Protocol (MCP) servers in Python and TypeScript.
Think through MCP server design step-by-step:
| Use Case | Transport | Why |
|---|---|---|
| Claude Desktop | stdio | Native support, simple setup |
| Web application | HTTP | Browser-compatible |
| High-scale deployment | HTTP (stateless) | Horizontal scaling |
| Local CLI tool | stdio | Pipes, process communication |
| Multi-user service | HTTP | Session management, CORS |
| Development/testing | stdio | Easier debugging |
<core_concepts>
Functions the LLM can call. Define: input schema, validation, structured output, clear description.
Data the LLM can read. Types: static (fixed URI) or dynamic (URI template with parameters). Include MIME type.
Reusable templates with arguments. Return formatted prompt text.
Shared capabilities: logging (stderr only), progress reporting, sampling (LLM generation), elicitation (user input).
</core_concepts>
resource://type/{id}<language_specific>
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("my-server")
@mcp.tool()
async def search_docs(query: str, limit: int = 10) -> list[dict]:
"""Search documentation by keyword. Use when the user asks about API usage."""
results = await doc_index.search(query, limit=limit)
return [{"title": r.title, "url": r.url, "snippet": r.snippet} for r in results]
@mcp.resource("docs://{topic}")
async def get_doc(topic: str) -> str:
"""Get documentation for a specific topic."""
return await doc_index.get(topic)
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
const server = new McpServer({ name: "my-server", version: "1.0.0" });
server.tool("search_docs", { query: z.string(), limit: z.number().default(10) }, async ({ query, limit }) => {
const results = await docIndex.search(query, limit);
return { content: [{ type: "text", text: JSON.stringify(results) }] };
});
</language_specific>
| Problem | Likely Cause | Fix |
|---|---|---|
| Schema validation fails | Type mismatch, missing required field | Check Pydantic/Zod schema vs input |
| Tools not appearing | Registration error | Verify decorator/method call, check logs |
| Transport errors | Malformed JSON-RPC | Validate message format, check stderr logs |
| Async errors | Blocking I/O | Ensure all I/O uses async/await |
| stdout corruption (stdio) | Logging to stdout | Redirect all logs to stderr |
from mcp.server.fastmcp import FastMCP
import httpx
mcp = FastMCP("weather")
@mcp.tool()
async def get_weather(city: str) -> dict:
"""Get current weather for a city. Use when the user asks about weather conditions."""
async with httpx.AsyncClient() as client:
resp = await client.get(f"https://api.weather.example/v1/{city}")
resp.raise_for_status()
data = resp.json()
return {"city": city, "temp_f": data["temp"], "condition": data["condition"]}
if __name__ == "__main__":
mcp.run(transport="stdio")
# Interactive testing
npx @modelcontextprotocol/inspector python -m my_server
# Manual stdio test
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python -m my_server
MCP server is complete when: