Skip to content

fix: fail fast when graphify.serve is launched interactively#312

Draft
lttlin wants to merge 1 commit intosafishamsi:v4from
lttlin:fix/issue-201-tty-guard
Draft

fix: fail fast when graphify.serve is launched interactively#312
lttlin wants to merge 1 commit intosafishamsi:v4from
lttlin:fix/issue-201-tty-guard

Conversation

@lttlin
Copy link
Copy Markdown

@lttlin lttlin commented Apr 13, 2026

Problem

Running python -m graphify.serve graphify-out/graph.json directly from an interactive terminal feeds the MCP stdio server an empty TTY stream. That bubbles up as a low-level JSON-RPC parse failure instead of explaining that the command must be launched by an MCP client.

Root Cause

graphify.serve immediately enters the stdio transport loop without checking whether stdin/stdout are attached to an interactive terminal. In that mode the MCP runtime tries to parse non-protocol input and reports an EOF/invalid JSON error.

Fix

Add an interactive-stdio guard before starting the MCP server. When stdin or stdout is a TTY, graphify.serve now prints a clear error and exits early instead of surfacing an internal server exception.

Validation

  • /tmp/graphify_issue_201/.venv/bin/python -m pytest tests/test_serve.py
  • Added coverage for pipe-like stdio and interactive TTY rejection

Closes #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error running MCP service

1 participant