judgevet.adapters.inbound.mcp
Status: draft.
judgevet.adapters.inbound.mcp
Inbound MCP stdio server.
This module provides an MCP server with three tools: ask_noul,
ask_choice, and ask_score. Each takes a state and an instruction,
then returns the corresponding answer as MCP structured content.
The factory wires module-level schemas and handlers and resolves the optional
SDK only when a caller constructs a server.
The server was tested with MCP Python SDK v2.2.0. Its
Server.run
delegates to the
compatibility loop.
The client's first request selects the legacy initialization path or the modern
per-request-envelope path. judgevet's subprocess test exercises the legacy
2025-03-26 lifecycle:
initialize, list tools and call all three tools. The modern path has not been
exercised here. The floor mcp>=2.2 reflects the tested SDK baseline.
Examples:
from judgevet.adapters.inbound.mcp import create_mcp_server
from judgevet.adapters.outbound.http import HTTPSystemOneAdapter
# The server takes a SystemOnePort, it does NOT construct an HTTP adapter
port = HTTPSystemOneAdapter(api_key="your-key")
server = create_mcp_server(port)
# Run the server over stdio
import anyio
from mcp.server.stdio import stdio_server
async def main():
async with stdio_server() as (read, write):
await server.run(read, write, server.create_initialization_options())
try:
anyio.run(main)
finally:
port.close()
The SDK uses snake_case for Python attributes (server_info,
structured_content, is_error) and camelCase for wire JSON fields
(serverInfo, structuredContent, isError). See the tagged
SDK type definitions.
See Also
- judgevet.ports.SystemOnePort: Protocol definition
- judgevet.adapters.outbound.http: HTTP adapter implementation
- judgevet.domain.answers: Answer types
- judgevet.domain.response: Response types
Attributes:
| Name | Type | Description |
|---|---|---|
SERVER_NAME |
str
|
The MCP server name. |
SERVER_VERSION |
str
|
The MCP server version, sourced from installed distribution metadata. |
Note
mcp is an optional extra (uv sync --extra mcp). An import-linter
contract forbids importing it in judgevet.domain, judgevet.ports and
judgevet.adapters.outbound. Factory and stdio entrypoint are inbound
adapters.
SERVER_NAME = 'judgevet-mcp'
module-attribute
SERVER_VERSION = version('judgevet')
module-attribute
create_mcp_server(port)
Create an MCP stdio server exposing the three judgment tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
SystemOnePort
|
Judgment port used for API calls. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
An SDK server with discovery and tool handlers. |
Raises:
| Type | Description |
|---|---|
ModuleNotFoundError
|
If the optional MCP runtime is unavailable. |
Note
Resolve SDK modules only when constructing a server. Library and CLI imports do not require the optional runtime. Architecture contracts keep MCP dependencies inside inbound adapters.