initial mcp server setup
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
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()
|
||||
Reference in New Issue
Block a user