feat(mcp): implement MCP server integration over stdio JSON-RPC #88
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/kronai!88
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/0026-implement-mcp-server"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement MCP server integration: spawn server processes via stdio, perform JSON-RPC initialize handshake, list tools, and convert to OpenAI function-calling format for the LLM client.
Why
MCP servers provide external tools that the LLM can use during job execution.
Testing
Breaking Changes
None.
Closes #0023
Closes #0024
Closes #0025
Closes #0026
Automated Review — PR #88
Result: APPROVED
Strong MCP implementation. The stdio JSON-RPC pattern is correctly implemented with initialize handshake, notifications, and tool listing.
llm.pychanged minimally to accepttoolsparam — nice encapsulation.MCPErrorfor missing command, FileNotFoundError, disconnected state, server errors, closed connections._send_request/_send_notification/_send_initializepattern is readable.Suggestions (non-blocking)
src/kronai/mcp.py:56,84— Docstrings still useRaises/Returnswithout trailing colon (same issue as PR #72). Inconsistent with the rest of the codebase:src/kronai/mcp.py:149-158—_send_requestreads a single stdout line. If the server writes enough stderr output before responding, the pipe buffer could fill and deadlock. Considerstderr=subprocess.DEVNULLif stderr isn't needed during normal operation, or read stderr asynchronously.src/kronai/mcp.py:169-174—json.loads()on the response line is not wrapped. If the server returns malformed JSON, ajson.JSONDecodeErrorpropagates instead ofMCPError. Wrap in a try/except.src/kronai/mcp.py:75-88—_send_initialize()doesn't validate the response. If the server returns{"result": {}}(empty), it logs and continues. Consider checking for expected fields likeserverInfoorprotocolVersion.