-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
47 lines (33 loc) · 1.16 KB
/
Copy pathserver.py
File metadata and controls
47 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
server.py — Entry point do MCP Server.
Inicia o servidor MCP via stdio (padrão para integração com Claude Desktop e agentes).
Uso:
python server.py
O servidor aguarda chamadas de tools via stdin e responde via stdout,
seguindo o protocolo MCP (Model Context Protocol).
"""
import asyncio
import os
import sys
from dotenv import load_dotenv
from mcp.server import Server
from mcp.server.stdio import stdio_server
# Carrega variáveis de ambiente do .env (se existir)
load_dotenv()
# Importa e registra as tools
from mcp_server.tools import register_tools
APP_NAME = "mcp-server-python"
APP_VERSION = "1.0.0"
async def main() -> None:
server = Server(APP_NAME)
register_tools(server)
print(f"[{APP_NAME} v{APP_VERSION}] Servidor MCP iniciado via stdio.", file=sys.stderr)
print(f"[{APP_NAME}] Tools disponíveis: search_knowledge_base, summarize_text, get_business_context", file=sys.stderr)
async with stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
server.create_initialization_options(),
)
if __name__ == "__main__":
asyncio.run(main())