Backup automatico script del 2026-09-27 07:00

This commit is contained in:
daniele committed 2026-09-27 07:00:02 +02:00
1 parent f347badf3b
commit 09dcbbdadb
24 files changed
+1164 -193

No files matched your search

+22 -6
View File
@@ -8,7 +8,20 @@ from typing import Any, Optional
from . import tools
LOGGER = logging.getLogger("loogle_mcp.server")
PROTOCOL_VERSION = "2024-11-05"
# Versioni supportate, dalla più recente: si risponde con quella chiesta dal client
# se supportata, altrimenti con la più recente (negoziazione MCP lifecycle)
SUPPORTED_PROTOCOL_VERSIONS = ("2025-06-18", "2025-03-26", "2024-11-05")
def negotiate_protocol_version(requested: Optional[str]) -> str:
if requested in SUPPORTED_PROTOCOL_VERSIONS:
return requested
return SUPPORTED_PROTOCOL_VERSIONS[0]
def expects_response(msg: Any) -> bool:
"""Solo le request JSON-RPC (method + id) hanno risposta; notifiche e response no."""
return isinstance(msg, dict) and "method" in msg and "id" in msg
def _error(req_id: Any, code: int, message: str) -> dict:
@@ -25,18 +38,21 @@ def handle_message(body: dict, claims: Optional[dict]) -> dict:
params = body.get("params") or {}
if method == "initialize":
requested = params.get("protocolVersion")
version = negotiate_protocol_version(requested)
LOGGER.info(
"initialize: client=%s protocollo richiesto=%s negoziato=%s",
(params.get("clientInfo") or {}).get("name"), requested, version,
)
return _result(
req_id,
{
"protocolVersion": PROTOCOL_VERSION,
"protocolVersion": version,
"capabilities": {"tools": {}, "resources": {}},
"serverInfo": {"name": "loogle-mcp", "version": "1.0.0"},
},
)
if method == "notifications/initialized":
return _result(req_id, {})
if method == "ping":
return _result(req_id, {})
@@ -75,4 +91,4 @@ def handle_message(body: dict, claims: Optional[dict]) -> dict:
def handle_batch(messages: list, claims: Optional[dict]) -> list:
return [handle_message(msg, claims) for msg in messages if isinstance(msg, dict)]
return [handle_message(msg, claims) for msg in messages if expects_response(msg)]
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.