Graphify-Labs/graphify · error · ValueError

Unknown resource: {uri_str}

Error message

Unknown resource: {uri_str}

What it means

Raised at the tail of the MCP read_resource handler (graphify/serve.py) when a client reads a resource whose uri_str matched none of the handled resource schemes/templates. Every recognized resource returns early; falling through to the final raise means the URI is outside the server's resource namespace.

Source

Thrown at graphify/serve.py:1973

                f"AMBIGUOUS: {confs.count('AMBIGUOUS')} ({round(confs.count('AMBIGUOUS')/total*100)}%)\n"
            )
        if uri_str == "graphify://questions":
            try:
                from graphify.analyze import suggest_questions
                community_labels = _load_community_labels()
                questions = suggest_questions(G, communities, community_labels, top_n=10)
                if not questions:
                    return "No suggested questions available."
                lines = ["Suggested questions:"]
                for q in questions:
                    if isinstance(q, dict):
                        lines.append(f"  - {q.get('question', '')}")
                    else:
                        lines.append(f"  - {q}")
                return "\n".join(lines)
            except Exception as exc:
                return f"Could not generate questions: {exc}"
        raise ValueError(f"Unknown resource: {uri_str}")

    async def call_tool(name: str, arguments: dict) -> list[types.TextContent]:
        arguments = dict(arguments or {})
        project_path = arguments.pop("project_path", None)
        handler = _handlers.get(name)
        if not handler:
            return [types.TextContent(type="text", text=f"Unknown tool: {name}")]
        try:
            _select_graph(project_path)  # bind G/communities to the target graph
            return [types.TextContent(type="text", text=handler(arguments))]
        except Exception as exc:
            return [types.TextContent(type="text", text=f"Error executing {name}: {exc}")]

    if hasattr(Server, "list_tools"):
        # mcp 1.x: decorator-based registration. The SDK wraps the raw returns
        # (list[Tool] -> ListToolsResult, str -> resource contents) itself.
        server = Server("graphify")
        server.list_tools()(list_tools)

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. List the server's actual resources first (MCP resources/list) and use a URI it returns verbatim.
  2. Match the scheme and path layout the server registers; do not invent graphify:// URIs from memory.
  3. After upgrading graphify, re-check the resource list for renames or removals.
  4. As a client, catch this ValueError on read_resource and show the URI to the user for correction.

Example fix

# before
await session.read_resource("graphify://unknown/thing")

# after
resources = await session.list_resources()
uri = next(r.uri for r in resources if "questions" in str(r.uri))
result = await session.read_resource(uri)
Defensive patterns

Strategy: validation

Validate before calling

# discover real URIs before reading
resources = await session.list_resources()
valid_uris = {str(r.uri) for r in resources}
assert str(want_uri) in valid_uris, f"unknown resource {want_uri}; have {sorted(valid_uris)}"

Type guard

def is_known_resource(uri: str, listed: set[str]) -> bool:
    return uri in listed

Try / catch

try:
    result = await session.read_resource(uri)
except ValueError as e:
    if str(e).startswith("Unknown resource"):
        listed = await session.list_resources()
        return error_to_user(f"{uri} not hosted; available: {[str(r.uri) for r in listed]}")
    raise

Prevention

When it happens

Trigger: An MCP client calls read_resource with an unknown URI — a mistyped path, a scheme the server does not host (e.g. graphify://graph vs whatever templates are registered), or a resource removed in this version. Note: unlike call_tool, read_resource lets the ValueError propagate rather than returning a soft error text.

Common situations: Hand-written MCP client configs referencing resource URIs guessed from docs of a different graphify version; stale clients after a server upgrade renamed/removed resources; URI typos or missing encoding.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/ea65757fedfdc9de. Report an issue: GitHub.