You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The @modelcontextprotocol/server-github doesn't work with python SDK. Here is code to reproduce
importosfrommcpimportClientSession, StdioServerParametersfrommcp.client.stdioimportstdio_clientimportdotenvdotenv.load_dotenv()
asyncdefmain():
server_params=StdioServerParameters(
command="npx",
args=["-y", "@modelcontextprotocol/server-github"],
env={
"GITHUB_PERSONAL_ACCESS_TOKEN": os.getenv("GITHUB_PERSONAL_ACCESS_TOKEN"),
"PATH": os.getenv("PATH")
}
)
asyncwithstdio_client(server_params) as (read, write):
asyncwithClientSession(read, write) assession:
# Initialize the connectionawaitsession.initialize()
# Example: Call tool to list repositoriesrepos=awaitsession.call_tool(
"search_repositories",
arguments={"query": "user:adhikasp"}
)
print("Repositories:", repos)
if__name__=="__main__":
importasyncioasyncio.run(main())
Output
$ python repro_github.py
GitHub MCP Server running on stdio
Traceback (most recent call last):
File "/mnt/e/Workspace/mcp-exploration/repro_github.py", line 26, in main
repos = await session.call_tool(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/e/Workspace/mcp-exploration/.venv/lib/python3.12/site-packages/mcp/client/session.py", line 163, in call_tool
return await self.send_request(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/e/Workspace/mcp-exploration/.venv/lib/python3.12/site-packages/mcp/shared/session.py", line 177, in send_request
return result_type.model_validate(response_or_error.result)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/e/Workspace/mcp-exploration/.venv/lib/python3.12/site-packages/pydantic/main.py", line 627, in model_validate
return cls.__pydantic_validator__.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for CallToolResult
content
Field required [type=missing, input_value={'toolResult': {'total_co...ault_branch': 'main'}]}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/missing
The server does work in inspector. Probably it have something to do with the Tool Result (Legacy) and the python sdk cannot parse legacy response?
The text was updated successfully, but these errors were encountered:
@hemangjoshi37a yes you should be able to use MCP servers with python
Example of simple python client in here https://github.com/adhikasp/mcp-client-cli
Right now it only implement the tool calling from the spec, not the resources and other stuff
The
@modelcontextprotocol/server-github
doesn't work with python SDK. Here is code to reproduceOutput
The server does work in inspector. Probably it have something to do with the
Tool Result (Legacy)
and the python sdk cannot parse legacy response?The text was updated successfully, but these errors were encountered: