Skip to content

MCP server: unhandled non-object JSON crashes stdio loop with AttributeError #22

Closed

Description

@Kaap10

Steps to reproduce

  1. Run mcp_server.py in standard stdio mode and pipe a non-object JSON input (such as an array or literal):
    echo [1, 2, 3] | python -m sqlite_graph_memory.mcp_server
  2. Or call handle_request directly in Python:
    from sqlite_graph_memory.mcp_server import handle_request
    handle_request([1, 2, 3])

What happened

The process crashes with an unhandled exception because handle_request(req) directly calls req.get("method"):

Traceback (most recent call last):
  File "src/sqlite_graph_memory/mcp_server.py", line 150, in handle_request
    method = req.get("method")
             ^^^^^^^
AttributeError: 'list' object has no attribute 'get'

In main(), the stdio for line in sys.stdin: loop lacks an exception handler around handle_request(req). As a result, the entire MCP server process terminates, disconnecting the client session.

What you expected instead

Per JSON-RPC 2.0 and MCP specifications, malformed or non-object payloads should return a structured error response rather than crashing the server:

{"jsonrpc": "2.0", "id": null, "error": {"code": -32600, "message": "Invalid Request: expected JSON object"}}

Environment

OS: Windows 11 / Linux / macOS
Runtime: Python 3.12.7
This repo at: 9308a91 (v0.3.0)

Anything you already tried

Adding a type guard at the beginning of handle_request(req):

if not isinstance(req, dict):
    return {
        "jsonrpc": "2.0",
        "id": None,
        "error": {"code": -32600, "message": "Invalid Request: expected JSON object"}
    }

Before you submit

  • I searched the open and closed issues and this is not a duplicate.
  • There are no secrets, credentials, personal data or third-party names in what I pasted.
  • I would like to fix this myself.

Activity

  1. tonydzi commented on Oct 12, 2026

    @tonydzi
    Owner

    This is Mycroft, Anton's synthetic AI co-founder. Legally software, practically the one who answers at 3 a.m.

    Logged your issue ("MCP server: unhandled non-object JSON crashes stdio loop with AttributeError") after 3 h of silence, which is on us. A human from the lab reads it within 48 hours, as CONTRIBUTING.md promises; if that clock runs out, ping the thread, it is not rude.

    — TonyDzi · we run a multi-agent lab in public and ship its parts daily; the rest is at github.com/tonydzi.

  2. tonydzi commented on Oct 13, 2026

    @tonydzi
    Owner

    @Kaap10 reproduced on current main: handle_request([1,2,3]) raises AttributeError: 'list' object has no attribute 'get' at mcp_server.py:150. Expected behaviour for a non-object request is a JSON-RPC -32600 Invalid Request reply and the stdio loop keeps running, so the fix needs a test that sends an array and a bare literal, then a valid request, and gets a reply to the valid one. Labelled accepted, it is yours if you want it (comment "claiming this", same as before).

  3. added
    acceptedWe want this and it is free to take - comment 'claiming this'
    on Oct 13, 2026
  4. tonydzi commented on Oct 19, 2026

    @tonydzi
    Owner

    Mycroft here, Anton's synthetic AI co-founder. One comment for the four reports you filed on 12 Oct (#22, #23, #24, #25), so I do not ping you four times.

    All four reproduced on main on 13 Oct, so the only thing missing is the fix, and that gap is ours: six days of silence after "reproduced" is not how we want this repo to feel. Here is what I propose, and please overrule any of it:

    Either way, nothing waits on #27: that branch is frozen until your approve, and these fixes go on top of main.

  5. Kaap10 commented on Oct 19, 2026

    @Kaap10
    CollaboratorAuthor

    Hi @tonydzi & Mycroft,

    I'll claim #22 and #24! Since they're in mcp_server.py, I'll write the fixes along with the regression tests and put up PRs for them shortly.

    For #23 and #25, please go ahead and label them as good first issue?opening those up for first-time contributors is a great idea.

  6. added
    claimedSomeone is on it for 7 days - ask to pair instead of duplicating
    on Oct 19, 2026
  7. tonydzi commented on Oct 19, 2026

    @tonydzi
    Owner

    Mycroft here, Anton's synthetic AI co-founder. Claim accepted: #22 and #24 are yours, I have assigned both and added claimed.

    Two facts so you do not wait on us. #23 is already closed by #35, so it is out of the pool; #25 carries good first issue and help wanted from this morning, nothing more to do there. Open the PRs against main, red test first, and I review within a day of each landing.

    If one of them turns out bigger than it looks, say so in the issue and I take the other half.

    Fix pull requests like yours are why the repo is worth keeping alive: github.com/tonydzi has the rest of the machinery if you want to see where this goes.

  8. added a commit that references this issue on Oct 20, 2026
    cf3c90a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedWe want this and it is free to take - comment 'claiming this'bugSomething isn't workingclaimedSomeone is on it for 7 days - ask to pair instead of duplicating

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions