Skip to content

Commit f0c0ecd

Browse files
authored
Fix host and port configuration issues - closes #83, closes #84 (#85)
1 parent a62ce1a commit f0c0ecd

File tree

5 files changed

+689
-92
lines changed

5 files changed

+689
-92
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ uvx excel-mcp-server streamable-http
8585
When running the server with the **SSE or Streamable HTTP protocols**, you **must set the `EXCEL_FILES_PATH` environment variable on the server side**. This variable tells the server where to read and write Excel files.
8686
- If not set, it defaults to `./excel_files`.
8787

88-
You can also set the `FASTMCP_PORT` environment variable to control the port the server listens on (default is `8000` if not set).
88+
You can also set the `FASTMCP_PORT` environment variable to control the port the server listens on (default is `8017` if not set).
8989
- Example (Windows PowerShell):
9090
```powershell
9191
$env:EXCEL_FILES_PATH="E:\MyExcelFiles"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "excel-mcp-server"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
description = "Excel MCP Server for manipulating Excel files"
55
readme = "README.md"
66
requires-python = ">=3.10"

src/excel_mcp/__main__.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import typer
32

43
from .server import run_sse, run_stdio, run_streamable_http
@@ -8,11 +7,8 @@
87
@app.command()
98
def sse():
109
"""Start Excel MCP Server in SSE mode"""
11-
print("Excel MCP Server - SSE mode")
12-
print("----------------------")
13-
print("Press Ctrl+C to exit")
1410
try:
15-
asyncio.run(run_sse())
11+
run_sse()
1612
except KeyboardInterrupt:
1713
print("\nShutting down server...")
1814
except Exception as e:
@@ -25,11 +21,8 @@ def sse():
2521
@app.command()
2622
def streamable_http():
2723
"""Start Excel MCP Server in streamable HTTP mode"""
28-
print("Excel MCP Server - Streamable HTTP mode")
29-
print("---------------------------------------")
30-
print("Press Ctrl+C to exit")
3124
try:
32-
asyncio.run(run_streamable_http())
25+
run_streamable_http()
3326
except KeyboardInterrupt:
3427
print("\nShutting down server...")
3528
except Exception as e:
@@ -42,9 +35,6 @@ def streamable_http():
4235
@app.command()
4336
def stdio():
4437
"""Start Excel MCP Server in stdio mode"""
45-
print("Excel MCP Server - Stdio mode")
46-
print("-----------------------------")
47-
print("Press Ctrl+C to exit")
4838
try:
4939
run_stdio()
5040
except KeyboardInterrupt:

src/excel_mcp/server.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
# Initialize FastMCP server
6767
mcp = FastMCP(
6868
"excel-mcp",
69+
host=os.environ.get("FASTMCP_HOST", "0.0.0.0"),
70+
port=int(os.environ.get("FASTMCP_PORT", "8017")),
6971
instructions="Excel MCP Server for manipulating Excel files"
7072
)
7173

@@ -666,7 +668,7 @@ def delete_sheet_columns(
666668
logger.error(f"Error deleting columns: {e}")
667669
raise
668670

669-
async def run_sse():
671+
def run_sse():
670672
"""Run Excel MCP server in SSE mode."""
671673
# Assign value to EXCEL_FILES_PATH in SSE mode
672674
global EXCEL_FILES_PATH
@@ -676,7 +678,7 @@ async def run_sse():
676678

677679
try:
678680
logger.info(f"Starting Excel MCP server with SSE transport (files directory: {EXCEL_FILES_PATH})")
679-
await mcp.run_sse_async()
681+
mcp.run(transport="sse")
680682
except KeyboardInterrupt:
681683
logger.info("Server stopped by user")
682684
except Exception as e:
@@ -685,7 +687,7 @@ async def run_sse():
685687
finally:
686688
logger.info("Server shutdown complete")
687689

688-
async def run_streamable_http():
690+
def run_streamable_http():
689691
"""Run Excel MCP server in streamable HTTP mode."""
690692
# Assign value to EXCEL_FILES_PATH in streamable HTTP mode
691693
global EXCEL_FILES_PATH
@@ -695,7 +697,7 @@ async def run_streamable_http():
695697

696698
try:
697699
logger.info(f"Starting Excel MCP server with streamable HTTP transport (files directory: {EXCEL_FILES_PATH})")
698-
await mcp.run_streamable_http_async()
700+
mcp.run(transport="streamable-http")
699701
except KeyboardInterrupt:
700702
logger.info("Server stopped by user")
701703
except Exception as e:

0 commit comments

Comments
 (0)