Skip to main content

Turn any Python library into an MCP Server

Project description

logo

Turn any Python library or your local script into an LLM Tool in seconds.

demo

allbemcp is a high-performance bridge that instantly exposes any Python environment—whether standard PyPI libraries or your own custom code—as a Model Context Protocol (MCP) server. It enables Large Language Models (Claude, ChatGPT, etc.) to execute local functions, manipulate dataframes, manage stateful objects, and interact with your system safely and efficiently.

Built on the latest StreamableHTTP protocol for maximum compatibility with Claude Desktop, LangChain, and Cursor.

Installation

pip install allbemcp

Usage Scenarios

allbemcp supports two primary use cases: exposing public libraries and exposing your own custom business logic.

1. Exposing Public Libraries

Expose pandas, numpy, or any other installed library to your LLM with a single command. allbemcp handles dependency installation and API generation automatically.

# Install, generate, and serve in one go
allbemcp start pandas

2. Exposing Custom Code

allbemcp treats your local Python scripts as first-class citizens. It parses type hints, docstrings, and class structures to generate high-quality tool definitions.

Step 1: Create your script (e.g., my_tools.py)

# my_tools.py
from typing import List

def calculate_bmi(weight_kg: float, height_m: float) -> float:
    """
    Calculate Body Mass Index (BMI).
    
    Args:
        weight_kg: Weight in kilograms.
        height_m: Height in meters.
    """
    return round(weight_kg / (height_m ** 2), 2)

class BankAccount:
    """A stateful class example."""
    def __init__(self, owner: str):
        self.owner = owner
        self.balance = 0

    def deposit(self, amount: float) -> str:
        self.balance += amount
        return f"Deposited ${amount}. New balance: ${self.balance}"

# Factory function to create instances
def open_account(owner: str) -> BankAccount:
    return BankAccount(owner)

Step 2: Start the server

# allbemcp detects the file in your current directory
allbemcp start my_tools

The LLM can now call calculate_bmi directly. Furthermore, if the LLM calls open_account, allbemcp automatically manages the returned BankAccount instance, allowing the LLM to make subsequent calls to deposit on that specific object.

Client Configuration

To use your tools with Claude Desktop or other MCP clients, add the corresponding configuration to your claude_desktop_config.json.

For a Library (e.g., pandas):

{
  "mcpServers": {
    "pandas": {
      "command": "uv",
      "args": ["run", "allbemcp", "start", "pandas"]
    }
  }
}

For Custom Code (e.g., my_tools):

{
  "mcpServers": {
    "my_tools": {
      "command": "uv",
      "args": ["run", "allbemcp", "start", "my_tools"],
      "cwd": "/absolute/path/to/your/script/directory"
    }
  }
}

Key Features

Zero-Config Introspection

Automatically inspects Python packages or local modules, extracts public APIs, and generates a fully compliant MCP server. No manual schema definition (YAML/JSON) is required.

Stateful Object Management

Unlike standard stateless tools, allbemcp supports object-oriented workflows:

  • Instance Persistence: When a function returns a class instance, it is stored in memory.
  • Method Chaining: LLMs can invoke methods on specific stored instances via a generated object_id.
  • Ideal For: Database connections, game states, simulation environments, and session-based workflows.

Smart Serialization Engine

LLMs struggle with complex objects. allbemcp handles them automatically:

  • DataFrames: Converted to markdown or JSON previews based on size.
  • Images: Automatically encoded or saved to temporary storage with resource links.
  • Iterators: Automatically consumed and summarized.

Local & Secure

Runs entirely on your machine. No data leaves your network. You control the host binding (default 127.0.0.1) and execution environment.

Advanced Usage

Inspect a Library

Check which functions will be exposed and view their quality scores before generating code:

allbemcp inspect numpy

Generate Only

Generate the server code without running it (useful for auditing or customization):

allbemcp generate matplotlib --output-dir ./my-server

License

This project is licensed under the AGPL v3 License.

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

allbemcp-1.1.1.tar.gz (60.4 kB view details)

Uploaded Source

Built Distribution

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

allbemcp-1.1.1-py3-none-any.whl (60.6 kB view details)

Uploaded Python 3

File details

Details for the file allbemcp-1.1.1.tar.gz.

File metadata

  • Download URL: allbemcp-1.1.1.tar.gz
  • Upload date:
  • Size: 60.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for allbemcp-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a1e6b79da14252fb22866ce76d0fc67721970b92675203f17bac4d7f0cd831c1
MD5 6839a0aeac343fb64610a0d7283ead88
BLAKE2b-256 3a3e7b6f536d74de37547d570513ac85b8bb94c8170402f3a125adb04ee88c33

See more details on using hashes here.

Provenance

The following attestation bundles were made for allbemcp-1.1.1.tar.gz:

Publisher: publish.yml on TingjiaInFuture/allbemcp

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

File details

Details for the file allbemcp-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: allbemcp-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 60.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for allbemcp-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6269f8a1abc8ec522ca7ad72333d01a9004ac715272819c0d21f66c574114be8
MD5 76f475b3445cacab7c3c0301727e5a84
BLAKE2b-256 45a9466d65c81f117bbbd71aa8c9dff2fcb4f7bb4c2a73c5be66e6ceecbfb204

See more details on using hashes here.

Provenance

The following attestation bundles were made for allbemcp-1.1.1-py3-none-any.whl:

Publisher: publish.yml on TingjiaInFuture/allbemcp

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