Index
mcp
¶
MCP (Model Context Protocol) layer for OpenJarvis.
Classes¶
MCPClient
¶
MCPClient(transport: MCPTransport)
Client that communicates with an MCP server via a transport.
| PARAMETER | DESCRIPTION |
|---|---|
transport
|
The transport layer to use for communication.
TYPE:
|
Source code in src/openjarvis/mcp/client.py
Functions¶
initialize
¶
Perform the MCP initialize handshake.
Returns the server capabilities.
Source code in src/openjarvis/mcp/client.py
list_tools
¶
list_tools() -> List[ToolSpec]
Discover available tools from the server.
Returns a list of ToolSpec objects.
Source code in src/openjarvis/mcp/client.py
call_tool
¶
Call a tool on the server.
Returns the result dictionary with content and isError fields.
Source code in src/openjarvis/mcp/client.py
MCPError
dataclass
¶
Bases: Exception
MCP protocol error with JSON-RPC error code.
MCPNotification
dataclass
¶
JSON-RPC 2.0 notification (no id, no response expected).
MCPRequest
dataclass
¶
JSON-RPC 2.0 request message.
Functions¶
to_json
¶
from_json
classmethod
¶
from_json(data: str) -> MCPRequest
Deserialize from JSON string.
Source code in src/openjarvis/mcp/protocol.py
MCPResponse
dataclass
¶
MCPResponse(result: Any = None, error: Optional[Dict[str, Any]] = None, id: int | str = 0, jsonrpc: str = '2.0')
JSON-RPC 2.0 response message.
Functions¶
to_json
¶
Serialize to JSON string.
from_json
classmethod
¶
from_json(data: str) -> MCPResponse
Deserialize from JSON string.
Source code in src/openjarvis/mcp/protocol.py
error_response
classmethod
¶
error_response(id: int | str, code: int, message: str, data: Any = None) -> MCPResponse
Create an error response.
Source code in src/openjarvis/mcp/protocol.py
MCPServer
¶
MCPServer(tools: Optional[List[BaseTool]] = None)
MCP server that exposes OpenJarvis tools via JSON-RPC.
| PARAMETER | DESCRIPTION |
|---|---|
tools
|
List of
TYPE:
|
Source code in src/openjarvis/mcp/server.py
Functions¶
handle
¶
handle(request: MCPRequest) -> MCPResponse
Dispatch an MCP request and return a response.
Source code in src/openjarvis/mcp/server.py
InProcessTransport
¶
InProcessTransport(server: MCPServer)
Bases: MCPTransport
Direct in-process transport for testing.
Routes requests directly to an MCPServer instance without
serialization overhead.
Source code in src/openjarvis/mcp/transport.py
Functions¶
send
¶
send(request: MCPRequest) -> MCPResponse
MCPTransport
¶
Bases: ABC
Abstract transport layer for MCP communication.
Functions¶
send
abstractmethod
¶
send(request: MCPRequest) -> MCPResponse
SSETransport
¶
Bases: MCPTransport
JSON-RPC over HTTP with Server-Sent Events.
Sends requests via HTTP POST and reads SSE responses.
Source code in src/openjarvis/mcp/transport.py
Functions¶
send
¶
send(request: MCPRequest) -> MCPResponse
Send request via HTTP POST.
Source code in src/openjarvis/mcp/transport.py
StdioTransport
¶
Bases: MCPTransport
JSON-RPC over stdin/stdout subprocess transport.
Launches a subprocess and communicates via JSON lines on stdin/stdout.
Source code in src/openjarvis/mcp/transport.py
Functions¶
send
¶
send(request: MCPRequest) -> MCPResponse
Write request as JSON line, read response line.