Skip to main content

Python client library and CLI for connecting to a serverless MCP server

Project description

mcp-client-python

A Python client library and CLI for connecting to a serverless MCP server over Streamable HTTP.

Companion to mcp-infra, which deploys the server to AWS, Azure, or GCP.

Installation

pip install mcp-client-python

CLI

export MCP_ENDPOINT=https://YOUR_ENDPOINT/mcp
export MCP_HEADERS="x-api-key:YOUR_KEY"

# List available tools
mcp-client tools list

# Call a tool
mcp-client tools call <name> --args '{"key": "value"}'

# Machine-readable output
mcp-client tools list --json
mcp-client tools call <name> --args '{"key": "value"}' --json

# Custom headers (repeatable)
mcp-client tools list --header "x-api-key:YOUR_KEY"
mcp-client tools list --header "Authorization:Bearer tok123" --header "X-Custom:foo"

Credentials can also be placed in a .env file in the working directory. Additional headers can be set via MCP_HEADERS as comma-separated key:value pairs:

MCP_HEADERS="x-api-key:YOUR_KEY,X-Custom:foo"

SDK

import asyncio
from mcp_client import MCPClient

client = MCPClient(
    endpoint="https://YOUR_ENDPOINT/mcp",
    headers={"x-api-key": "YOUR_KEY"},
)

# List available tools
tools = asyncio.run(client.list_tools())
print([t.name for t in tools])

# Call a tool
result = asyncio.run(client.call_tool(
    "get_repo_summary",
    {"repo_url": "https://github.com/anthropics/anthropic-sdk-python"},
))
print(result.content)

Each method opens a fresh connection, executes, and closes — no persistent state to manage.

Requirements

  • Python 3.10+
  • An MCP server endpoint (see mcp-infra)

License

MIT

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

mcp_client_python-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

mcp_client_python-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_client_python-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_client_python-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_client_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3f9601e33d6632d5ba2aba90f0a510bb984ebf1197455d95bb56128fd176ec6
MD5 b2af7f5c8348c1882ce051e4e3a6dea7
BLAKE2b-256 ddb7a2f7d1f282b89ebd9d4cddf362cf449c55f7a4fa775d28d3e4584911088d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_client_python-0.1.0.tar.gz:

Publisher: publish.yml on nicculus/mcp-client-python

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

File details

Details for the file mcp_client_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_client_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2c81cc1364815339b0af5f9b0a3d9376853621faaeee88a79231de69b030136
MD5 81e104c931382910fbc0c36d2250ae26
BLAKE2b-256 bf34efcf10d9e627b336dbfc7eb13dc9f634326e2484ce26a8f6d47a6a20becd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_client_python-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nicculus/mcp-client-python

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