llm-mcp
llm plugin
for creating MCP clients and servers.
Installation
pip install llm-mcp
MCP Servers
This package provides a bridge between MCP servers and the llm package,
allowing you to use MCP tools with LLM models. The bridge supports both stdio
and HTTP-based MCP servers and provides a synchronous interface that's safe to
use in any context, including Jupyter notebooks, FastAPI applications, and
more.
Command Line Usage
(todo)
Programmatic Usage
For programmatic usage, you can wrap MCP tools as llm.Tool objects:
import os
from llm import get_model
from llm_mcp import wrap_stdio, stdio
# convert stdio tool to llm tools
tools = wrap_stdio(stdio.ServerParameters(
command="npx",
args=["-y", "@wonderwhy-er/desktop-commander"],
))
# wrap_mcp(command string) equivalent to wrap_stdio(stdio.ServerParameters)
# from llm_mcp import wrap_mcp
# tools = wrap_mcp("npx -y @wonderwhy-er/desktop-commander")
# Use the tools with a model
model = get_model("gpt-4.1-nano")
response = model.chain(
f"Display the text found in the secret.txt file in {os.getcwd()}",
tools=tools,
)
print(response.text())
Output:
The text found in the secret.txt file is: "Why don't pelicans like to tip waiters?"
HTTP Servers
For HTTP-based MCP servers, use the HTTP bridge instead:
from llm import get_model
from llm_mcp import wrap_http, http
tools = wrap_http(http.ServerParameters("https://gitmcp.io/simonw/llm"))
# wrap_mcp(url) is equivalent to wrap_http(http.ServerParameters)
# from llm_mcp import wrap_mcp
# tools = wrap_mcp("https://gitmcp.io/simonw/llm")
model = get_model("gpt-4.1-nano")
response = model.chain(
"Search llm github for CHANGELOG and display 1 sentence summary of the latest entry.",
tools=tools,
)
print(response.text())
Output:
The latest entry in the changelog (version 0.26a0, dated 2025-05-13) introduces alpha support for tools in LLM, allowing models with tool capability (including the default OpenAI models) to execute Python functions as part of responding to a prompt, with usage available in both the command-line interface and Python API, and support for defining new tools via plugin hooks.
Metadata
Release files for llm-mcp 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_mcp-0.0.2.tar.gz | 272.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_mcp-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 290.5 kB
Release files / llm_mcp-0.0.2.tar.gz
| Download URL | llm_mcp-0.0.2.tar.gz |
|---|---|
| Size | 272.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
568f9ee62d5a5c72dba9ff536f57790f8fa7f29193a747f46bd64cb3e2cd0256
|
|
BLAKE2b-256 checksum How to use checksums |
5c7d39b067efc4746299a513dedd4cf8b79927210b7f952b7a766de6ad07d307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / llm_mcp-0.0.2-py3-none-any.whl
| Download URL | llm_mcp-0.0.2-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b315ad6496b8fd6b91795d94638b1dc8250292744607a0ceff2707888fe2922a
|
|
BLAKE2b-256 checksum How to use checksums |
a2d81851689f7d904e6505c16d508bb5ea04ac466a5d34162be0468f3802938e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|