Feat/add stdio transport (#25)

* feat: Add stdio transport method.
Update relevant documentation and code to support both SSE and stdio connection methods, initialize the EXCEL_FILES_PATH variable and perform the corresponding path handling.

* Remove PyPI mirror configuration.
This commit is contained in:
allenZhang
2025-05-17 22:39:06 +08:00
committed by GitHub
parent 46adf0b173
commit bbab5bf184
4 changed files with 131 additions and 54 deletions

View File

@ -1,13 +1,19 @@
import asyncio
from .server import run_server
import typer
from typing import Optional
def main():
"""Start the Excel MCP server."""
from .server import run_sse, run_stdio
app = typer.Typer(help="Excel MCP Server")
@app.command()
def sse():
"""Start Excel MCP Server in SSE mode"""
print("Excel MCP Server - SSE mode")
print("----------------------")
print("Press Ctrl+C to exit")
try:
print("Excel MCP Server")
print("---------------")
print("Starting server... Press Ctrl+C to exit")
asyncio.run(run_server())
asyncio.run(run_sse())
except KeyboardInterrupt:
print("\nShutting down server...")
except Exception as e:
@ -15,7 +21,21 @@ def main():
import traceback
traceback.print_exc()
finally:
print("Server stopped.")
print("Service stopped.")
@app.command()
def stdio():
"""Start Excel MCP Server in stdio mode"""
try:
run_stdio()
except KeyboardInterrupt:
print("\nShutting down server...")
except Exception as e:
print(f"\nError: {e}")
import traceback
traceback.print_exc()
finally:
print("Service stopped.")
if __name__ == "__main__":
main()
app()