AGENT SKILL

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

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.md when the request is broader than MCP.
  • Use ../server-basics/SKILL.md when the user needs the underlying LitAPI, 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

  1. Confirm the runtime has fastmcp installed. LitServe MCP construction raises a runtime error when MCP support packages are unavailable.
  2. Create an MCP object with at least a useful description; optionally set a unique name and a manual input_schema.
  3. Pass the MCP object into the LitAPI constructor (super().__init__(mcp=...) or a base class that accepts mcp). This connects the MCP object to the LitAPI; do not call private connection methods in user code.
  4. Prefer automatic schema extraction from decode_request when the endpoint accepts a Pydantic request model or well-annotated parameters. Use a manual input_schema only when it matches the actual LitServe endpoint handler arguments.
  5. 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.
  6. Tell MCP clients to connect to the same host and port with the /mcp/ suffix, for example http://localhost:8000/mcp/.
  7. 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 a LitAPI, using Pydantic/type-hint schemas, checking the tool object, connecting clients, and Claude Desktop setup.
  • references/troubleshooting.md — common failures: missing fastmcp, 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) accepts description, input_schema, and name.
  • extract_input_schema(func) -> dict[str, Any] is available from litserve.mcp.
  • _python_type_to_json_schema and _param_name_to_title are available helper functions.
  • MCP.as_tool() requires a connected LitAPI and returns a ToolEndpointType with name, description, inputSchema, and endpoint.
  • 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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351