mirror of
https://github.com/haris-musa/excel-mcp-server.git
synced 2025-12-17 19:26:39 +08:00
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:
@ -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()
|
||||
Reference in New Issue
Block a user