Skip to main content

Python SDK for CircuitNotion MCP Server

Project description

CircuitNotion MCP SDK

Python SDK for the CircuitNotion MCP server.

Installation

pip install cn-mcp

For local development against a local MCP server:

export MCP_API_KEY="your-api-key"
export MCP_BASE_URL="http://localhost:8000"

Quick Start

from cn_mcp import MCPClient

client = MCPClient(api_key="your-api-key")

session = client.sessions.create()
workspace = client.bind_session(session["session_id"])

file_resp = client.files.write(
    session_id=session["session_id"],
    path="output/hello.txt",
    content="Hello, World!",
)
print(file_resp["download_url"])

result = workspace.tool_call("terminal_exec", cmd="echo hello")
print(result["stdout"])

devices = client.devices.list()
print(devices)

client.sessions.dispose(session["session_id"])

For agentic workflows, bind_session() keeps session-backed tools aligned with the published MCP metadata without manually injecting session_id.

Dynamic Tool Calling

The SDK now reads the live tool contract from the server, so list_tools() and tool_call() stay aligned with the deployed MCP.

from cn_mcp import MCPClient

client = MCPClient(api_key="your-api-key")

print(client.list_tools())

result = client.tool_call("device_set_state", device_name="kitchen", state="on")
print(result)

Use get_tools() or get_tool_schema("tool_name") if you want the full published metadata from /mcp/tools.

Main APIs

Sessions

session = client.sessions.create()
sessions = client.sessions.list()
client.sessions.dispose(session["session_id"])

Files

file_resp = client.files.write(session["session_id"], "reports/out.zip", b"zip bytes")
files = client.files.list(session["session_id"])
content = client.files.download(file_resp["file_id"])
client.files.delete(file_resp["file_id"])

download_url values returned by the server are concrete absolute URLs when the server knows its public base URL from the request.

Terminal

result = client.terminal.execute(
    session_id=session["session_id"],
    command="python --version",
    timeout_minutes=60,
    output_limit_kb=1024,
)

The SDK defaults to a longer HTTP timeout for agent workflows. You can override it globally with MCPClient(timeout=...) or env MCP_HTTP_TIMEOUT_SECONDS.

Search

results = client.search.web("CircuitNotion")
print(results["organic_results"])

Devices

devices = client.devices.list()
result = client.devices.set_state(device_name="living room light", state="off")

Scheduler

task = client.scheduler.schedule(payload={"message": "follow up"}, in_seconds=300)
tasks = client.scheduler.list()
client.scheduler.cancel(task["task_id"])

Database

rows = client.db.query(
    session_id=session["session_id"],
    sql="SELECT name FROM sqlite_master WHERE type = ?",
    params=["table"],
)

client.db.execute(
    session_id=session["session_id"],
    # db.execute supports INSERT/UPDATE/DELETE statements.
    # This example assumes a `notes` table already exists.
    sql="INSERT INTO notes (body) VALUES (?)",
    params=["hello"],
)

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

cn_mcp-0.3.5.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

cn_mcp-0.3.5-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file cn_mcp-0.3.5.tar.gz.

File metadata

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

File hashes

Hashes for cn_mcp-0.3.5.tar.gz
Algorithm Hash digest
SHA256 f3556dca383e81cd98cf581d025154971cd709eac3063d1779dc5f05b684262b
MD5 1eac07bfdd0e14e42260e6f944db4dd4
BLAKE2b-256 336ddc5ee23137a7b700a21f55736c5a035650edf9e27446bc538aef00a79439

See more details on using hashes here.

Provenance

The following attestation bundles were made for cn_mcp-0.3.5.tar.gz:

Publisher: pypi-publish.yml on ntirushwajeanmarc/cn-mcp-sdk

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

File details

Details for the file cn_mcp-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: cn_mcp-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cn_mcp-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 00560d3b888671b5bf48eff569c611d32aaf29d3e1ceec78deb249eed9d76dd1
MD5 37dccd6cc8fa3da5577550bb5ea24c37
BLAKE2b-256 56b6565dfff1497005bd61cc32c8069eda7205def89fa64b10192fc4ae82a0f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cn_mcp-0.3.5-py3-none-any.whl:

Publisher: pypi-publish.yml on ntirushwajeanmarc/cn-mcp-sdk

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