Skip to main content

Access tools from MCP servers as LLM tools

Project description

llm-mcp-client

PyPI Changelog Tests License

Access tools from MCP servers as LLM tools

Installation

Install this plugin in the same environment as LLM.

llm install llm-mcp-client

Usage

This plugin registers a toolbox called MCP which connects to an MCP server, discovers the tools it exposes and makes them available as LLM tools.

Pass the URL of an MCP server to the toolbox:

llm -T 'MCP("https://example.com/mcp")' 'Ask something that needs a tool' --td

The --td option shows details of the tool calls as they execute.

It works in llm chat too:

llm chat -T 'MCP("https://example.com/mcp")'

Protocol modes

By default the client negotiates the protocol automatically. You can force a specific mode with the mode= argument:

# Force modern stateless MCP:
llm -T 'MCP("https://example.com/mcp", mode="stateless")' '...'
# Force the legacy initialize handshake:
llm -T 'MCP("https://example.com/mcp", mode="legacy")' '...'

Tool name prefixes

If you are using tools from more than one server and their names might clash, give each server a prefix:

llm -T 'MCP("https://one.example.com/mcp", prefix="one_")' \
    -T 'MCP("https://two.example.com/mcp", prefix="two_")' '...'

Python API

import llm
from llm_mcp_client import MCP

model = llm.get_model("gpt-4.1-mini")
result = model.chain(
    "Ask something that needs a tool",
    tools=[MCP("https://example.com/mcp")],
).text()

Tool results containing MCP image or audio content are returned to the model as LLM attachments. An MCP error result raises llm_mcp_client.MCPToolError, which LLM passes back to the model as an error message.

Development

To set up this plugin locally, first checkout the code. Then run the tests with uv:

cd llm-mcp-client
uv run pytest

To run LLM with your in-development plugin:

uv run llm --help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_mcp_client-0.1a0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_mcp_client-0.1a0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file llm_mcp_client-0.1a0.tar.gz.

File metadata

  • Download URL: llm_mcp_client-0.1a0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llm_mcp_client-0.1a0.tar.gz
Algorithm Hash digest
SHA256 f1c55e7d82a662e411ab36c61576d6b67d4e54ad5879dd761e7d396a3ef58784
MD5 f18db6265e7069c260d7c72c2d0f8af6
BLAKE2b-256 e0eabfde7813e1b3387858f4bcb905ddd0452b8a68ba16f7a8239b720c8fdcc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_mcp_client-0.1a0.tar.gz:

Publisher: publish.yml on simonw/llm-mcp-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_mcp_client-0.1a0-py3-none-any.whl.

File metadata

  • Download URL: llm_mcp_client-0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llm_mcp_client-0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 97fe39d4508262f48ace8e83ddb5d76269896e30e7a886391720f6ec8bfd2b59
MD5 6ab7f8ec72d1af84eb9cd219d1bb7259
BLAKE2b-256 e2c7c290918fbeb1dbc99d22388f05756d9f20ad1d4c17e34204ce092ae70a66

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_mcp_client-0.1a0-py3-none-any.whl:

Publisher: publish.yml on simonw/llm-mcp-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page