Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Issues and solutions for connecting stdio client to the example server #6

Description

@jtorreggiani

I ran into a couple of issues with connecting a client to the example server.

I was able to make the following changes to enable the client to connect to the server. The changes can be see in the repo https://github.com/jtorreggiani/test-python-mcp-server/blob/main/src/test_server/server.py. Note: I am running the code on a MacBook.

  1. Adding shebang to the top of the file
#!/usr/bin/env python3
  1. Adding a conditional runner to the end of the script.
if __name__ == "__main__":
    asyncio.run(main())
  1. Update the permissions on the file
chmod a+x src/test_server/server.py

I wrote a test https://github.com/jtorreggiani/test-python-mcp-server/blob/main/src/test_server/test_client.py to exercise all the server methods. I ran into an issue with the following line where the tests would hang on this line.

# Notify clients that resources have changed
await server.request_context.session.send_resource_list_changed()

I observed the same issue running the code in a simple chatbot outside of the test environment. It is unclear if there is something the client should be doing to unblock this request or if this doesn't need an await.

I tried to creating a separate executable in a couple of ways that would be passed to StdioServerParameters, but only could get the client to connect if I updated the main server.py file.

server_params = StdioServerParameters(
    command=f"{test_dir}/server.py",
    args=[],
    env=None
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions