hexastack-mcp
Model Context Protocol (MCP) adapter and AI agent tool integration for Hexastack.
Part of the Hexastack Framework · Governed by Hexaqual.
1. Overview & Capabilities
hexastack-mcp exposes Hexastack application services directly to AI agents (Claude Desktop, Cursor, Antigravity, custom LLM agents) via the official Anthropic Model Context Protocol:
- Automatic CQRS Tool Generation (
@mcp_tool): Decorates CQRS Command and Query models, converting them into structured LLM tools with JSON Schema validation. - Resource URI Providers (
@mcp_resource): Exposes read endpoints and system diagnostics as readable MCP resources (hexastack://schema,hexastack://info). - Prompt Templates (
@mcp_prompt): Configures reusable workflow prompts for LLM clients. - Multiple Transports:
- Standard I/O (
stdio): Local process communication for desktop assistants and subprocess agents. - Server-Sent Events (
sse): HTTP SSE transport via FastAPI for remote agent networks.
- Standard I/O (
- Metrics & Observability (
McpMetricsMiddleware): Tracks tool, resource, and prompt execution throughput and duration metrics againstMetricsPort. - Single-Pass Reflection: Discovers decorated tools and resources in Phase 3 module scanning via
create_mcp_visitor.
2. Package Anatomy & Key Components
hexastack_mcp/
├── domain/ # McpToolMetadata, McpResourceMetadata, McpPromptMetadata, McpError
├── adapters/ # stdio runner, sse/FastAPI router, FastMCP server wrapper
└── infra/
├── bootstrap.py # McpBootstrapper (order=40)
├── config.py # HexastackMcpConfig
├── decorators.py# @mcp_tool, @mcp_resource, @mcp_prompt
├── autodiscovery.py # create_mcp_visitor
└── registries/ # server.py (McpServerRegistry)
Key Exports
| Category | Exports |
|---|---|
| Adapters | run_stdio_server, create_sse_router, mount_mcp_sse |
| Bootstrap | McpBootstrapper (order=40), HexastackMcpConfig |
| Decorators | @mcp_tool, @mcp_resource, @mcp_prompt |
| Registries | McpServerRegistry, get_mcp_registry |
3. Monorepo & Sibling Relationships
graph TD
subgraph Agents ["AI Agent Clients (Claude, Cursor, Antigravity)"]
STDIO_CLIENT["Local Desktop / Subprocess (stdio)"]
SSE_CLIENT["Remote Agent Network (SSE / HTTP)"]
end
subgraph McpAdapter ["hexastack-mcp"]
SERVER["FastMCP / MCP Server"]
REG["McpServerRegistry (Tools, Resources, Prompts)"]
DISPATCH["CQRS Tool Dispatcher"]
end
subgraph CQRSExecution ["hexastack-cqrs"]
CBUS["CommandBusPort"]
QBUS["QueryBusPort"]
end
subgraph WebIntegration ["hexastack-fastapi (Optional)"]
FASTAPI_APP["FastAPI Application (SSE Endpoint)"]
end
STDIO_CLIENT --> SERVER
SSE_CLIENT --> FASTAPI_APP
FASTAPI_APP --> SERVER
SERVER --> REG
REG --> DISPATCH
DISPATCH -->|dispatches commands| CBUS
DISPATCH -->|dispatches queries| QBUS
Explicit Dependencies (Direct)
hexastack-core: DI container, configuration registry, base exceptions.hexastack-cqrs:CommandBusPortandQueryBusPortfor message dispatching.mcp>=1.3.0: Official Anthropic Model Context Protocol SDK.
Implied / Behavioral Relationships (DI-Mediated)
- FastAPI SSE Integration:
McpBootstrapper(order=40) attaches SSE endpoints to the activeFastAPIinstance whenhexastack-fastapiis present andauto_mount_fastapi=true. - CQRS Dispatching: When an LLM executes an MCP tool, the adapter resolves
CommandBusPortorQueryBusPortto run the command through the full middleware pipeline.
Optional Integrations (Extras)
[fastapi]: Installshexastack-fastapiandfastapi>=0.141.1for remote SSE transport over HTTP.
4. Installation
# Standalone stdio transport
pip install hexastack-mcp
# With FastAPI remote SSE transport
pip install "hexastack-mcp[fastapi]"
# Via umbrella package
pip install "hexastack[mcp]"
5. Configuration Reference
[hexastack.mcp]
server_name = "Hexastack MCP Server"
server_version = "0.1.0"
sse_path = "/sse" # Route prefix for SSE transport
auto_mount_fastapi = true # Auto-mount SSE router into FastAPI on bootstrap
6. Quickstart Example
from dataclasses import dataclass
from hexastack_core.infra.bootstrap import bootstrap
from hexastack_cqrs.domain.query import Query
from hexastack_cqrs.infra.decorators import query_handler
from hexastack_mcp.infra.decorators import mcp_tool
# 1. Define CQRS Query & Handler
@dataclass(frozen=True)
class CheckSystemStatusQuery(Query):
service: str = "database"
@query_handler(CheckSystemStatusQuery)
class CheckSystemStatusHandler:
def __call__(self, qry: CheckSystemStatusQuery) -> dict[str, str]:
return {"service": qry.service, "status": "HEALTHY"}
# 2. Expose as MCP Tool for AI Agents
mcp_tool(
name="check_status",
description="Check the real-time operational status of internal subsystems.",
)(CheckSystemStatusQuery)
# 3. Bootstrap Runtime and Run MCP Server
runtime = bootstrap(packages_to_scan=[__name__])
mcp_server = runtime.get("mcp_server")
Metadata
Release files for hexastack-mcp 0.11.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hexastack_mcp-0.11.3.tar.gz | 13.4 kB | Without provenance | Details for hexastack_mcp-0.11.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hexastack_mcp-0.11.3-py3-none-any.whl | Python 3 | none | any | Details for hexastack_mcp-0.11.3-py3-none-any.whl |
Total release size: 32.1 kB
Release files / hexastack_mcp-0.11.3.tar.gz
| Download URL | hexastack_mcp-0.11.3.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7fe885939ae21c959e61327880dbe7253af672f8232da2a0b135722c036a26f
|
|
BLAKE2b-256 checksum How to use checksums |
dd93af3ec086ef06a7ed21cac48e1d58032edeae7f92ff4526d81952cb7c887f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / hexastack_mcp-0.11.3-py3-none-any.whl
| Download URL | hexastack_mcp-0.11.3-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03282fe3bcf5ae4553a98a17158d414203c94a524e492405dbc2beeacbba5234
|
|
BLAKE2b-256 checksum How to use checksums |
214dcb063cac2ff5e811633f55326cdb21b009f54001702467a9fa84694a2b92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for hexastack-mcp 0.11.3
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.