mcp
Expose LitServe LitAPI endpoints as Model Context Protocol tools with schema extraction, streamable HTTP mounting, and connection troubleshooting.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- mcp
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Expose LitServe LitAPI endpoints as Model Context Protocol tools with schema extraction, streamable HTTP mounting, and connection troubleshooting.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md9.5 KB
- 参考文档references/troubleshooting.md8.4 KB
- 参考文档references/workflows.md7.6 KB
- 脚本scripts/mcp_server.py3.2 KB
03 SKILL.md 正文
LitServe MCP sub-skill
Use this sub-skill when a user wants to expose a LitAPI as a Model Context Protocol (MCP) tool, build or debug the tool schema, mount the streamable HTTP MCP route, or connect an MCP client such as Claude Desktop to a LitServe app.
Routing
- Start here for requests like “add MCP to my LitServe app”, “make a tool from
decode_request”, “why does MCP say it is not connected”, “mount the streamable HTTP MCP route”, or “build the MCP schema from Pydantic/type hints”. - Use the root LitServe router at
../../SKILL.mdwhen the request is broader than MCP. - Use
../server-basics/SKILL.mdwhen the user needs the underlyingLitAPI,LitServer, request/response, batching, streaming, auth, middleware, or deployment model first. - Route OpenAI-compatible chat and embedding endpoint work to
../openai-specs/SKILL.md. - Do not cover benchmark-only, torch-heavy, parity-throughput, or accelerator-specific workflows here.
Operating checklist
- Confirm the runtime has
fastmcpinstalled. LitServe MCP construction raises a runtime error when MCP support packages are unavailable. - Create an
MCPobject with at least a usefuldescription; optionally set a uniquenameand a manualinput_schema. - Pass the
MCPobject into theLitAPIconstructor (super().__init__(mcp=...)or a base class that acceptsmcp). This connects the MCP object to theLitAPI; do not call private connection methods in user code. - Prefer automatic schema extraction from
decode_requestwhen the endpoint accepts a Pydantic request model or well-annotated parameters. Use a manualinput_schemaonly when it matches the actual LitServe endpoint handler arguments. - Build the server with
ls.LitServer(api)and run it normally. LitServe registers the tool and mounts the streamable HTTP MCP app automatically when MCP support is available. - Tell MCP clients to connect to the same host and port with the
/mcp/suffix, for examplehttp://localhost:8000/mcp/. - If the client lists the tool but tool calls fail, debug the schema shape, tool name uniqueness, and endpoint path mapping before changing core server code.
Reference map
references/api-reference.md— exact MCP constructor behavior, schema helper behavior, connector internals, and streamable HTTP route details.references/workflows.md— copyable patterns for adding MCP to aLitAPI, using Pydantic/type-hint schemas, checking the tool object, connecting clients, and Claude Desktop setup.references/troubleshooting.md— common failures: missingfastmcp, disconnected MCP, missing name/description, malformed schema, endpoint collisions, missing mounted route, beta warning, and Claude Desktop confusion.scripts/mcp_server.py— safe bundled example adapted from LitServe MCP behavior; it can print the generated tool metadata or run a local MCP-enabled LitServe server.
Facts to preserve
MCP(description=None, input_schema=None, name=None)acceptsdescription,input_schema, andname.extract_input_schema(func) -> dict[str, Any]is available fromlitserve.mcp._python_type_to_json_schemaand_param_name_to_titleare available helper functions.MCP.as_tool()requires a connectedLitAPIand returns aToolEndpointTypewithname,description,inputSchema, andendpoint.- The tool name is sanitized by removing a leading slash and replacing remaining slashes with underscores.
- The MCP streamable HTTP endpoint is
/mcp/on the LitServe server. - MCP support is beta and its APIs may change.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).