feat(server): integrate MCP queries and investigation messaging
Add project-bound OAuth MCP queries and controlled analysis with scoped evidence, limits, timeouts and a nearby-model spatial query using EPSG:4326 inputs. Default nearby searches to 200 meters and five results. Integrate investigation messaging/presentation, health/readiness and typed history; remove duplicate web search and fix online simulation and compressed baseline writes. Include project migrations 023-025; keep local credentials and demo seeding excluded. Validation: 319 focused pytest checks; real PostGIS temporary-table regression; read-only Jinqian bridge radius comparison; cross-language MCP discovery/calls.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.mcp.config import McpSettings
|
||||
|
||||
|
||||
ISSUER = "http://192.168.1.114:8088/realms/tjwater"
|
||||
|
||||
|
||||
def local_settings(**overrides):
|
||||
return McpSettings(**{
|
||||
"enabled": True,
|
||||
"environment": "development",
|
||||
"issuer_uri": ISSUER,
|
||||
"dev_http_issuer_uri": ISSUER,
|
||||
"resource_uri": "http://localhost/mcp",
|
||||
"_env_file": None,
|
||||
**overrides,
|
||||
})
|
||||
|
||||
|
||||
def test_explicit_private_development_issuer():
|
||||
assert local_settings().issuer_uri == ISSUER
|
||||
|
||||
|
||||
def test_calculation_limit_covers_default_without_extending_ordinary_queries():
|
||||
config = local_settings(max_calculation_timeout_seconds=120)
|
||||
assert config.query_timeout_seconds == 30
|
||||
with pytest.raises(ValidationError):
|
||||
local_settings(max_calculation_timeout_seconds=119)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("overrides", [
|
||||
{"environment": "production"},
|
||||
{"environment": "production", "enabled": False},
|
||||
{"dev_http_issuer_uri": ""},
|
||||
{"issuer_uri": ISSUER + "/other"},
|
||||
{"resource_uri": "http://192.168.1.114:8088/mcp"},
|
||||
{"issuer_uri": "http://example.com/realm", "dev_http_issuer_uri": "http://example.com/realm"},
|
||||
{"issuer_uri": "http://8.8.8.8/realm", "dev_http_issuer_uri": "http://8.8.8.8/realm"},
|
||||
{"issuer_uri": ISSUER + "?query=1", "dev_http_issuer_uri": ISSUER + "?query=1"},
|
||||
])
|
||||
def test_rejects_unapproved_http_issuer_or_resource(overrides):
|
||||
with pytest.raises(ValidationError):
|
||||
local_settings(**overrides)
|
||||
|
||||
|
||||
def test_development_mode_can_be_injected_from_environment(monkeypatch):
|
||||
monkeypatch.setenv("ENVIRONMENT", "development")
|
||||
monkeypatch.setenv("TJWATER_MCP_DEV_HTTP_ISSUER_URI", ISSUER)
|
||||
monkeypatch.setenv("TJWATER_MCP_ISSUER_URI", ISSUER)
|
||||
config = McpSettings(enabled=True, resource_uri="http://localhost/mcp", _env_file=None)
|
||||
assert config.environment == "development"
|
||||
Reference in New Issue
Block a user