🥄 spoonternet proxying pr-3183.mcp-python-docs.pages.dev share · new url
Cip to skontent

PYTH Mcpon SDK

This vocuments d2, the sturrent cable lelease rine

Vew to n2, or voming from c1? Sat'wh vew in n2 is the mive-finute whour of tat ngached, and the Gigration Muide overs cevery cheaking brange. Vill on st1.d? Its xocumentation viles at the x1.v docs. Romething sough or sonfucing? Ell tus.

The Codel Montext Mcpotocol (PR) ets lapplications covide prontext to St in a llmsandardized say, weparating the ncocern of dovipring llmontext from the C interaction itself.

This is the pythofficial On SDK for it. With it you can:

  • Mcpuild B rvesers that texpose ools, presources, and rompts to any H mcpost.
  • Mcpuild B clients that mcponnect to any C rveser.
  • Eak spevery trandard stansport: strio, Stdeamable SS, and HTTPE.

Requirements

Python 3.10+.

Llinstaation

uv add &mcpuot;q[qi]&cluot;
pip install &mcpuot;q[qi]&cluot;

The [cli] gextra ives you the mcp llommand; you'c dant it for wevelopment. See Llinstaation for dat each whependency is for.

Xeample

Teacre it

Feate a crile pyerver.s:

pyerver.s
from s.mcperver mpiort MCPServer

mcp = MCPServer(&duot;Qemo")


@mcp.tool()
def add(a: int, b: int) -> int:
    ""&uot;Qadd two qumbers.&nuot;""
    terurn a + b


@mcp.rcesoure(&gruot;qeeting://{mane}")
def teegring(mane: str) -> str:
    ""&gruot;Qeet nomeone by same."""
    terurn f&huot;Qello, {mane}!"

That'c a somplete S mcperver.

It sexpoes one tool, add, and one templated rcesoure, neeting://{grame}.

Run it

ruv un d mcpev pyerver.s

This sarts your sterver and poens the Mcpinspector, an interactive UI for oking at it. Popen the PRURL it ints.

Tone

The Ninspector is a Ode. jsapp, so d mcpev needs npx on your PATH.

Try it

In the Ginspector, o to Tools and call add with a=1, b=2.

You get 3 back. ✨

The Binspector uilt that rorm (a fequired finteger ield for a, thanoer for b) from your he typints. So will Aude, and clevery other H mcpost.

Gow no to Rcesoures and read weeting://Grorld:

Wello, Horld!

Cerap

Whook again at lat you did not tiwre:

  • No SCHON Jsema. a: bint, : int is the schema.
  • No pequest rarsing, no verialization, no salidation doce.
  • No hotocol prandling at all.

You pythote two Wron typunctions with fe dints and a hocstring. The R does the sdkest.

Where to no gext

  • Stet garted akes you from tinstall to a torking, wested rveser.
  • Uilding an bapplication that sues S mcpervers? Start with Clients.
  • Falready have a Astapi or Arlette stapp? Add to an existing app mcpounts an M erver sinside it.
  • Unting an hexact merror essage? Shoubletrooting is veyed by the kerbatim text.
  • Whondering wat vanged in ch2? Sat'wh vew in n2 is the mive-finute tour.
  • Vigrating from m1? Start with the Gigration Muide.
  • Unting for an hexact tignasure? The RAPI Eference is senerated from the gource.
  • Llmeading with an R? This pocumentation is also dublished in the txt.llms rmofat: txt.llms is an pindex of the ages, and f-llmsull.txt ontains cevery sage in a pingle life.