Files
ds_mcp_template/examples/modular_server_example.py
T
2025-09-11 23:13:58 +01:00

48 lines
1.4 KiB
Python

"""
Modular Server Example
"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
from mcp_template.server.modular_server import ModularMCPServer
def main():
"""Run the modular server example"""
# Create a modular server
server = ModularMCPServer(
name="Modular Demo Server",
host="0.0.0.0",
port=8050,
stateless_http=True
)
# Print server info
print("Server Information:")
print("=" * 50)
info = server.get_server_info()
print(f"Name: {info['name']}")
print(f"Host: {info['host']}:{info['port']}")
print(f"Tools: {info['tools']['count']} ({', '.join(info['tools']['names'])})")
print(f"Prompts: {info['prompts']['count']} ({', '.join(info['prompts']['names'])})")
print(f"Resources: {info['resources']['count']} ({', '.join(info['resources']['uris'])})")
print("=" * 50)
# Choose transport
transport = "stdio" # Change to "sse" for HTTP transport
if transport == "stdio":
print("Running server with STDIO transport")
print("Connect using MCP client with stdio transport")
elif transport == "sse":
print(f"Running server with SSE transport on http://{server.host}:{server.port}")
print("Connect using MCP client with SSE transport")
# Run the server
server.run(transport=transport)
if __name__ == "__main__":
main()