Skip to content

Commit 59031f5

Browse files
Add stdio transport (#8)
1 parent fc1b073 commit 59031f5

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ install:
1414

1515
format:
1616
uv run ruff format .
17+
uv run ruff check --fix .
1718

1819
lint:
1920
uv run ruff check .

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ Perfect for enhancing AI conversations with data visualization capabilities. The
6161
```json
6262
{
6363
"mcpServers": {
64-
"math": {
65-
"command": "npx",
64+
"plotting": {
65+
"command": "uvx",
6666
"args": [
67-
"mcp-remote",
68-
"http://localhost:9090/mcp"
67+
"--from", "/path/to/plotting-mcp",
68+
"plotting-mcp", "--transport=stdio"
6969
]
7070
}
7171
}

src/plotting_mcp/server.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,30 @@ def health_check(request: Request) -> Response:
111111
is_flag=True,
112112
help="Enable auto-reload for development (default: False)",
113113
)
114-
def main(log_level: str = "INFO", reload: bool = False) -> None:
114+
@click.option(
115+
"--transport",
116+
default="http",
117+
type=click.Choice(["stdio", "http"]),
118+
help="Transport type for the MCP server (default: http)",
119+
)
120+
def main(log_level: str = "INFO", reload: bool = False, transport: str = "http") -> None:
115121
"""Main entry point for the MCP server."""
116122
logging_dict = configure_logging(log_level=log_level)
117-
uvicorn.run(
118-
"plotting_mcp.server:starlette_app",
119-
host=mcp.settings.host,
120-
port=mcp.settings.port,
121-
log_config=logging_dict,
122-
reload=reload,
123-
reload_dirs=[str(Path(__file__).parent.absolute())],
124-
timeout_graceful_shutdown=2,
125-
)
123+
124+
if transport == "stdio":
125+
mcp.run("stdio")
126+
elif transport == "http":
127+
uvicorn.run(
128+
"plotting_mcp.server:starlette_app",
129+
host=mcp.settings.host,
130+
port=mcp.settings.port,
131+
log_config=logging_dict,
132+
reload=reload,
133+
reload_dirs=[str(Path(__file__).parent.absolute())],
134+
timeout_graceful_shutdown=2,
135+
)
136+
else:
137+
raise ValueError(f"Unsupported transport type: {transport}")
126138

127139

128140
if __name__ == "__main__":

0 commit comments

Comments
 (0)