Spaces:
Running
Gradio MCP Integration problem
I have a really hard time to replicate some of the course example is because library version or other technical issu related. The last one concern the communication between an LLM model/client Claude and the count_letter tool publish on the huggingface space.
None of the config provided that I add to claude_desktop_config.json are working
So I get thta Claude only take STDIO, so I copy the config provided:
{
"mcpServers": {
"gradio": {
"command": "npx",
"args": [
"mcp-remote",
"/gradio_api/mcp/sse",
"--transport",
"sse-only"
]
}
}
}
But I get the error in the log:
[gradio] Unexpected token 'P', "Please set"... is not valid JSON
[gradio] Server transport closed
I have absolutly no d--- idea of what this 'P' token is since there is no token at all. I tried to provide a huggin token if it is not a private repo, but didn't work at all any expert here ?
Best Regards.
That Unexpected token P usually means the client expected JSON but received plain text beginning with “Please ...”. In this setup I would check the raw response from the MCP URL first.
A few things to verify:
- the Space is public or the auth token is actually being sent
- the URL points to the MCP/SSE endpoint, not the normal app page
- the Space is awake and not returning a setup/login/error message
mcp-remoteand Gradio versions match the course instructions
If you open the endpoint or curl it and the first text is Please set..., that message is the real clue. The JSON parser is just where the mismatch becomes visible.
That Unexpected token P usually means the MCP client expected JSON but received a plain text response starting with “Please ...”. I would debug the raw endpoint before changing the Claude config again.
A quick checklist:
- Open or curl the exact
/gradio_api/mcp/sseURL and look at the first bytes returned. - Confirm the Space is public, awake, and not showing a setup/auth/runtime message.
- Make sure the URL is the Space app URL, not the repo page URL.
- Upgrade
mcp-remoteand Gradio to the versions assumed by the course. - If auth is required, verify the token is being passed by
mcp-remote, not just available locally.
The useful clue is the text behind the P, not the JSON parser error. Once you know the actual response body, it is usually clear whether the issue is endpoint path, Space startup, auth, or transport mismatch.