From 0eb5181d129e7aa8c536b6c21b4f0806bd7b1551 Mon Sep 17 00:00:00 2001 From: Vyacheslav-Tomashevskiy Date: Thu, 2 Jul 2026 10:48:05 +0200 Subject: [PATCH] fix: make README programmatic example importable (closes #250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The README 'For Other MCP Clients' quick-start showed: from rustchain_mcp import RustChainMCPServer server = RustChainMCPServer(api_key="your-api-key") but no RustChainMCPServer symbol (and no api_key constructor) exists — rustchain_mcp/__init__.py exported only __version__, and the server is a module-level FastMCP instance (rustchain_mcp/server.py -> mcp = FastMCP(...)), which is what the rustchain-mcp console script already runs ([project.scripts] rustchain_mcp.server:mcp.run). Following the documented example therefore raised ImportError. Fix: - Re-export the real server instance from the package (from .server import mcp), matching the issue's suggested fix of exporting the documented symbol. - Update the README example to the working API: from rustchain_mcp import mcp; mcp.run(). Verified: 'from rustchain_mcp import mcp; mcp.run' now imports cleanly and the console entry point is unchanged. --- README.md | 11 ++++++++--- rustchain_mcp/__init__.py | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9a24bfd..c9d0f59 100644 --- a/README.md +++ b/README.md @@ -94,11 +94,16 @@ Add to your Claude config file (`~/Library/Application Support/Claude/claude_des ### For Other MCP Clients +Any MCP-compatible client can launch the `rustchain-mcp` console script directly +(same as the Claude Desktop config above). To embed or run the server +programmatically, import the FastMCP server instance and run it: + ```python -from rustchain_mcp import RustChainMCPServer +from rustchain_mcp import mcp -server = RustChainMCPServer(api_key="your-api-key") -server.run() +# Configuration is read from environment variables (all optional): +# RUSTCHAIN_NODE, BOTTUBE_URL, BEACON_URL, RUSTCHAIN_TIMEOUT +mcp.run() # serves over stdio by default ``` ## Prerequisites diff --git a/rustchain_mcp/__init__.py b/rustchain_mcp/__init__.py index 640459d..dffc9c1 100644 --- a/rustchain_mcp/__init__.py +++ b/rustchain_mcp/__init__.py @@ -1,3 +1,12 @@ """RustChain + BoTTube MCP Server — AI agent tools for the RustChain blockchain and BoTTube video platform.""" __version__ = "0.4.0" + +# Re-export the FastMCP server instance so it can be used programmatically: +# from rustchain_mcp import mcp +# mcp.run() +# This is the same object the ``rustchain-mcp`` console script runs +# (see [project.scripts] in pyproject.toml -> rustchain_mcp.server:mcp.run). +from .server import mcp + +__all__ = ["mcp", "__version__"]