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?
@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
Activity
dsp-ant commentedon Nov 27, 2024
Thank you for reporting. I take a look
hemangjoshi37a commentedon Dec 1, 2024
Do we compulsorily need to use the app or we can interface with MCP with python ? this is somewhat confusing
adhikasp commentedon Dec 2, 2024
@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
toolcalling from the spec, not theresourcesand other stuffhemangjoshi37a commentedon Dec 2, 2024
@adhikasp actually I already tried using with python but it throws so many errors
adhikasp commentedon Dec 4, 2024
The github servers x python SDK is fixed by modelcontextprotocol/servers#176 👍