Connection Error - Check if your MCP server is running and proxy token is correct
Hi,
I'm creating an issue similar to #724 .
I've tried all of the recommendations in issue #724 with the same connection issue. Below is my code for my mcp_server.py.
I'm unable to progress in the tutorial at this point in time.
Any help would be greatly appreciated.
mcp.server.py*
from pydantic import Field # type: ignore from mcp.server.fastmcp import FastMCP # type: ignore
mcp = FastMCP("DocumentMCP", log_level="ERROR")
docs = { "deposition.md": "This deposition covers the testimony of Angela Smith, P.E.", "report.pdf": "The report details the state of a 20m condenser tower.", "financials.docx": "These financials outline the project's budget and expenditures.", "outlook.pdf": "This document presents the projected future performance of the system.", "plan.md": "The plan outlines the steps for the project's implementation.", "spec.txt": "These specifications define the technical requirements for the equipment.", }
@mcp.tool( name="read_doc_contents", description="Reads the contents of a specified document and returns it as a string.", ) def read_document( doc_id: str = Field(description="The ID of the document to read."), ):
if doc_id not in docs:
raise ValueError(f"Document with ID '{doc_id}' not found.")
return docs[doc_id]
@mcp.tool(
name="edit_document",
description="Edits the contents of a specified document with new content.",
)
def edit_document(
doc_id: str = Field(description="The ID of the document to edit."),
old_str: str = Field(description="The string to be replaced in the document."),
new_str: str = Field(description="The new content to write into the document."),
):
if doc_id not in docs:
raise ValueError(f"Document with ID '{doc_id}' not found.")
docs[doc_id] = docs[doc_id].replace(old_str, new_str)
return f"Document '{doc_id}' has been updated."
TODO: Write a resource to return all doc id's
TODO: Write a resource to return the contents of a particular doc
TODO: Write a prompt to rewrite a doc in markdown format
TODO: Write a prompt to summarize a doc
if name == "main": mcp.run(transport="stdio")
MCP Inspector needs to verbosely print (the reason) what was it expecting from the server and what did it find instead.
I have frequently run into this issue in MCP Inspector even when the MCP server is up, maybe with a bit of incorrect protocol implementation (in my MCP server) that I am trying to debug using MCP Inspector.