Skip to main content

LMCP Tool Builder - A tool for discovering, building and loading tools from LMCP servers

Project description

LMCP Tool Builder

A Python library for discovering, building and loading tools from LMCP (Language Model Context Protocol) servers.

Features

  • Tool Discovery: Automatically discover tools from LMCP servers
  • Local Caching: Cache tools locally for offline use
  • Auto Update: Configurable auto-update behavior
  • Tool Testing: Built-in testing functionality for discovered tools
  • Easy Integration: Simple API for integrating with your applications

Installation

pip install lmcp-tool-builder

Quick Start

from lmcp_tool_builder import LMCPToolBuilder
import os

# Create a tool builder instance
builder = LMCPToolBuilder(
    server_url="http://your-lmcp-server:8000",
    api_key=os.getenv("LMCP_API_KEY"),
    local_tools_file="bot_tools.py",
    debug=True,
    auto_update=True
)

# Build and load tools
tools = builder.build_and_load_tools()

# Use the tools
for tool in tools:
    print(f"Tool: {tool.__name__}")

Configuration

Environment Variables

Create a .env file in your project:

LMCP_API_KEY=your_api_key_here
LMCP_LOCAL_TOOLS_FILE=bot_tools.py

LMCPToolBuilder Parameters

  • server_url: URL of the LMCP server (default: "http://localhost:8000")
  • api_key: API key for authentication (default: "")
  • local_tools_file: Path to local tools cache file (default: "bot_tools.py")
  • debug: Enable debug output (default: False)
  • auto_update: Auto-update tools from server (default: False)

API Reference

LMCPToolBuilder Class

Methods

  • discover_tools(): Discover tools from LMCP server or local cache
  • build_tools_module(server_tools): Build a Python module from server tools
  • save_tools_module(module_code): Save module to local file
  • load_tools_from_module(): Load tools from local module
  • build_and_load_tools(): Main method to build and load tools
  • test_tools(tools): Test loaded tools with sample inputs

Example Usage

import os
from dotenv import load_dotenv
from lmcp_tool_builder import LMCPToolBuilder

# Load environment variables
load_dotenv()

# Initialize builder
builder = LMCPToolBuilder(
    server_url="http://aicity.wang:8000",
    api_key=os.getenv("LMCP_API_KEY"),
    local_tools_file=os.getenv("LMCP_LOCAL_TOOLS_FILE", "bot_tools.py"),
    debug=True,
    auto_update=True
)

# Build and load tools
tools = builder.build_and_load_tools()

# Test tools
builder.test_tools(tools)

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/example/lmcp-tool-builder.git
cd lmcp-tool-builder

# Install in development mode
pip install -e .

Running Tests

python -m pytest tests/

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

lmcp_tool_builder-0.1.3.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

lmcp_tool_builder-0.1.3-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file lmcp_tool_builder-0.1.3.tar.gz.

File metadata

  • Download URL: lmcp_tool_builder-0.1.3.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for lmcp_tool_builder-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fa8197069b2a7a3f3d2a3492646231e8b6bd36892efc4dfb2e2a7ff3db022036
MD5 e11e653b134cb9bd4c5c65efa5c4e942
BLAKE2b-256 4fe791346779a7a453dd5396aea631eafca6fdeb19efe8a8fae3bd98ae75f720

See more details on using hashes here.

File details

Details for the file lmcp_tool_builder-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for lmcp_tool_builder-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 daadc3d9cf9398f1aadedaa830da5f5e91826bef06b1a83436376085e8df3ca2
MD5 8501c80ae67cf1e4cdafead18d024ceb
BLAKE2b-256 e240f43d463a844949b734a91ca8aabb0a81da56e6e1d517cb0a8ca45255ce38

See more details on using hashes here.

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