Skip to main content

Python SDK for the OpenTool MCP server — manage tools, auth, and API keys programmatically.

Project description

opentool-sdk (Python)

Python SDK for the OpenTool MCP server. Manage tools, auth, and API keys programmatically.

Both sync and async clients included.

Install

pip install opentool-sdk

Quick Start (Sync)

from opentool import OpenTool

client = OpenTool(
    base_url="http://localhost:3001",
    api_key="ot_your_key_here",
)

# Check server health
health = client.health()

# List all available tools
tools = client.tools.list()

# List your connected tools
connected = client.tools.connected()

# Execute a tool
result = client.tools.execute("github.create_issue", {
    "owner": "user",
    "repo": "my-repo",
    "title": "Created via SDK",
    "body": "This issue was created programmatically.",
})

Quick Start (Async)

from opentool import AsyncOpenTool

async with AsyncOpenTool(
    base_url="http://localhost:3001",
    api_key="ot_your_key_here",
) as client:
    tools = await client.tools.connected()
    result = await client.tools.execute("slack.send_message", {
        "channel": "#general",
        "text": "Hello from the SDK",
    })

Auth

# Sign up (auto-sets API key on this client)
res = client.auth.signup(email="dev@example.com", password="my-password", name="Dev")
print(res.api_key)

# Login
res = client.auth.login(email="dev@example.com", password="my-password")

# Get OAuth URL for a provider
url = client.auth.get_connect_url("github")
# → User visits this URL to authorize

# Disconnect a provider
client.auth.disconnect("github")

API Keys

# List active keys
keys = client.keys.list()

# Create a new key (raw key returned once)
new_key = client.keys.create("CI pipeline")
print(new_key.key)

# Revoke a key
client.keys.revoke(key_id)

User Profile

# Get your profile
me = client.users.me()
print(me.email, me.connected_tools_count)

# Update profile
client.users.update_me(name="New Name")

Tools

# All tools in the registry
all_tools = client.tools.list()

# Tools you've connected
mine = client.tools.connected()

# Tools for a specific provider
github_tools = client.tools.by_provider("github")

# Execute a tool via MCP
result = client.tools.execute("slack.send_message", {
    "channel": "#general",
    "text": "Hello from the SDK",
})

Error Handling

from opentool import OpenTool, OpenToolError, AuthenticationError

try:
    client.tools.connected()
except AuthenticationError:
    print("API key is invalid or expired")
except OpenToolError as e:
    print(f"Error {e.status}: {e.body}")

Context Manager

# Sync
with OpenTool(base_url="http://localhost:3001", api_key="ot_xxx") as client:
    tools = client.tools.list()

# Async
async with AsyncOpenTool(base_url="http://localhost:3001", api_key="ot_xxx") as client:
    tools = await client.tools.list()

Configuration

client = OpenTool(
    base_url="http://localhost:3001",  # Required
    api_key="ot_xxx",                  # Optional — set later with client.set_api_key()
    timeout=30.0,                      # Request timeout in seconds (default: 30)
    http_client=custom_httpx_client,   # Custom httpx.Client instance
)

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

opentool_sdk-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

opentool_sdk-0.1.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file opentool_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: opentool_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for opentool_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 27cd913012ff8c390b4305f5068c2402a2d9162cbe546a1cf55c57ac132a1910
MD5 fd7afcc84edf3a99b19a225db30f4c76
BLAKE2b-256 da25116fec668fa28721c1a07e56c02dd130717c7c95ec6cbe92db7fb3ef86b2

See more details on using hashes here.

File details

Details for the file opentool_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: opentool_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for opentool_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e5675abe4d2565e52441785d174e7a14ec2a0064c1e463072682f39ce4f69ce
MD5 e8f32b2300b443b710051ca5f66d9321
BLAKE2b-256 2a58bbada3ecd32e3ddf0af1ffdd36b94ca28b7343e9cb6ac4fe29fac0e8f327

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