Skip to main content

MCP Server Core 🚀

Universal MCP Server Framework for Streamable HTTP ASGI, Cloudflare Tunnel, OAuth 2.1, System Tray & Process Supervisor

Decoupled, reusable transport, lifecycle, and scaffolding foundation for FastMCP services (e.g. Codexen, Literary Workflow).

PyPI version Python versions License: MIT


📦 Features

  • ⚡ Fast Project Scaffolding (mcp-server-core init): Bootstrap complete, production-ready, standardized MCP services in seconds with tray supervisor, console launcher, batch scripts, and .env pre-configured.
  • 🌐 ASGI Streamable HTTP Transport: Starlette + FastMCP integration supporting SSE, streaming, and atomic JSON-RPC responses.
  • 🛡️ Cache-Busting & Anti-Stale Guarantees: Built-in NoCacheMiddleware ensuring Cache-Control: no-cache, no-store, must-revalidate across all discovery and tool execution routes.
  • 🔐 Embedded OAuth 2.1 Server: Full RFC 9728, RFC 8414, RFC 7591 (Dynamic Client Registration), and PKCE S256 support for ChatGPT Developer Mode & third-party AI agents.
  • 🚇 Cloudflare Tunnel Singleton Supervisor: Outbound named tunnel daemon lifecycle management with automated health check and heartbeat recovery.
  • 🔍 Cascading Cloudflared Discovery:
    1. Direct parameter cloudflared_path
    2. Environment variable CLOUDFLARED_PATH or CLOUDFLARED_BIN
    3. Package binary directory (mcp_server_core/bin/cloudflared.exe)
    4. Project workspace directory (./bin/cloudflared.exe)
    5. User global cache directory (~/.mcp/bin/cloudflared.exe)
    6. System PATH (shutil.which)
    7. Automated download via mcp-server-core download-cloudflared
  • 🖥️ System Tray Supervisor (BaseTrayApp): Clean Windows tray app supporting dynamic High-DPI icon drawing, single-instance process supervision via Windows Job Objects, URL/Token copy menus, and custom project management actions.
  • 🚀 Unified Console Launcher (launch_service): Port checking, stale PID cleanup, tunnel heartbeat monitoring, and credential masking.
  • 📋 Envelope Response Model (ToolResultListDict): Dual-access envelope format supporting both dict indexing (res["projects"]) and list sequence operations (len(res), res[0]).

🛠️ CLI Utilities

1. Rapidly Scaffold a New MCP Service

mcp-server-core init my-novel-service --port 8790 --char N --color "#0984e3"

Generated project structure:

my-novel-service/
├── app/
│   ├── __init__.py
│   ├── __main__.py      # python -m app entrypoint
│   ├── server.py        # FastMCP + serve_http setup
│   └── tools.py         # MCP tool functions
├── launcher.py          # Unified console launcher with tunnel guards
├── tray_app.py          # Windows System Tray supervisor
├── start.bat            # One-click start (tray silent mode preferred)
├── stop.bat             # One-click stop
├── .env.example         # Configuration template
├── .env                 # Pre-generated secure MCP_API_KEY
├── pyproject.toml
└── README.md

2. Check Tunnel, Ports & Environment Status

mcp-server-core status

3. Download Official Cloudflared Binary

# Downloads official release for current OS & architecture
mcp-server-core download-cloudflared

💻 Installation & Usage

1. From PyPI

pip install mcp-server-core
# or with tray support
pip install "mcp-server-core[tray]"

# or using uv
uv add "mcp-server-core[tray]"

2. Python Code Usage

Launcher (launcher.py):

from mcp_server_core import launch_service
from app.server import main as server_main

if __name__ == "__main__":
    launch_service(
        service_name="My Custom MCP Server",
        default_port=8790,
        server_runner=server_main,
    )

System Tray App (tray_app.py):

from mcp_server_core import BaseTrayApp

class CustomTrayApp(BaseTrayApp):
    def __init__(self):
        super().__init__(
            service_name="My Custom MCP Server",
            port=8790,
            tray_title="My Custom MCP Server",
            icon_text="M",
            icon_bg_color="#00b894",
        )

if __name__ == "__main__":
    app = CustomTrayApp()
    app.run()

Dual-Access Response Format:

from mcp_server_core import ToolResultListDict

@mcp.tool()
def list_projects() -> dict:
    projects = [{"id": 1, "name": "demo"}]
    return ToolResultListDict(projects, key="projects", status="success")

📄 License

MIT License.

Metadata

Release files for mcp-server-core 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-core 0.3.5
File Size Uploaded Provenance Actions
mcp_server_core-0.3.5.tar.gz 44.9 kB Without provenance Details for mcp_server_core-0.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-core 0.3.5
File Interpreter ABI Platform Actions
mcp_server_core-0.3.5-py3-none-any.whl Python 3 none any Details for mcp_server_core-0.3.5-py3-none-any.whl

Total release size: 93.8 kB

Release files / mcp_server_core-0.3.5.tar.gz

Download URL mcp_server_core-0.3.5.tar.gz
Size 44.9 kB
Tags Source
SHA-256 checksum
How to use checksums
acb8418dcbab9678e744ceb069b3e6f8c560718cb3567b22060536882686c659
BLAKE2b-256 checksum
How to use checksums
ce494bdd6df1e1825dd12cf797b6aab39c08cb667ce21fba45d048ec6902ded4
Upload date
Uploaded using Trusted Publishing?
What is 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":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mcp_server_core-0.3.5-py3-none-any.whl

Download URL mcp_server_core-0.3.5-py3-none-any.whl
Size 48.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
680ad27c9a1f0567bea9d27375de1d685d9efb5d7536987fd8fc31fa2b9652c9
BLAKE2b-256 checksum
How to use checksums
39b4d93f7768361427105ce4737855e57c2ec4583830c33ac567ea3aa8d41bc2
Upload date
Uploaded using Trusted Publishing?
What is 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":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mcp-server-core 0.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page