Shared utilities for mrlesmithjr MCP servers: logging, config, paths, errors
Project description
mrlesmithjr-mcp-common
Shared building blocks for FastMCP servers: stderr-safe logging, layered configuration, XDG path resolution, and a consistent JSON error envelope. It is the common foundation under the mrlesmithjr/mcp tool suite, but has no dependency on those tools and is usable in any MCP server.
Import as mcp_common.
Install
pip install mrlesmithjr-mcp-common
# or
uv add mrlesmithjr-mcp-common
Usage
import json
from mcp_common.server import build_server, run_stdio
from mcp_common.errors import safe_tool
mcp = build_server("my-tool", instructions="What this server does.")
@mcp.tool()
@safe_tool
def do_thing(x: str) -> str:
return json.dumps({"status": "ok", "data": x})
def main() -> None:
run_stdio(mcp)
safe_tool wraps a tool so unhandled exceptions return a structured {"error": ...} envelope instead of crashing the server. build_server and run_stdio handle FastMCP setup and stdio transport; configure_logging() forces logs to stderr (stdout is reserved for the protocol).
Modules
| Module | Purpose |
|---|---|
mcp_common.logging |
configure_logging() forcing stderr output (required for stdio transport) |
mcp_common.server |
build_server(name, instructions) and run_stdio(mcp) |
mcp_common.config |
load_layered_config(tool_name, env_map): env vars > config.json > .env fallback |
mcp_common.paths |
config_dir(), config_file(), data_dir() XDG path resolvers |
mcp_common.errors |
tool_error(), error_json(), safe_tool decorator |
mcp_common.coordinator_events |
emit_coordinator_event(source, event_type, payload) -> bool: self-healing write onto homeops-coordinator's events.db bus. Never raises; returns False on failure so callers can fire-and-forget it after a state change. |
Requirements
- Python 3.11+
License
MIT. Part of the mrlesmithjr/mcp workspace.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mrlesmithjr_mcp_common-0.1.1.tar.gz.
File metadata
- Download URL: mrlesmithjr_mcp_common-0.1.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cae341c91c1b628e3f22136a6ce5f9497ad78024cd33675103ab85e024f181fc
|
|
| MD5 |
bda1b883d8e472401eb52bb09bff5a36
|
|
| BLAKE2b-256 |
d59413834471b757a80b7757bf54c24eb2a038c23ca97dcaeb58ab12c1438b2f
|
File details
Details for the file mrlesmithjr_mcp_common-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mrlesmithjr_mcp_common-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8220bafc196b80da5588a96c1948ab55c03cd34cd1c52a2763c25d09f0cec6d2
|
|
| MD5 |
3238c58f09bc7dde14540529688ed89c
|
|
| BLAKE2b-256 |
3526b821acfb5789da6cf2cc9d29c60538d1082befa16b4af7064d9b1a0faf01
|