Skip to content

MCP Client connecting to an already running MCP Server? #145

@sidharthrajaram

Description

@sidharthrajaram

In the example, the MCP Client is responsible for starting the MCP server process like:

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

# Create server parameters for stdio connection
server_params = StdioServerParameters(
    command="python", # Executable
    args=["example_server.py"], # Optional command line arguments
    env=None # Optional environment variables
)

async def run():
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the connection
            await session.initialize()
            ...

Let's say I have the MCP server running already (i.e. uv run example_server.py).

How can MCP clients connect to that server?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions