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:
+14
-7
@@ -1,6 +1,7 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from urllib.parse import quote_plus
|
||||
from pydantic import AliasChoices, Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
@@ -25,6 +26,9 @@ class Settings(BaseSettings):
|
||||
TIMESCALEDB_DB_PORT: str = "5433"
|
||||
TIMESCALEDB_DB_USER: str = "postgres"
|
||||
TIMESCALEDB_DB_PASSWORD: str = "password"
|
||||
TIMESCALEDB_REALTIME_MAX_DECOMPRESSED_TUPLES: int = Field(
|
||||
default=1_000_000, ge=1, le=2_147_483_647,
|
||||
)
|
||||
# Metadata Database Config (PostgreSQL)
|
||||
METADATA_DB_NAME: str = "system_hub"
|
||||
METADATA_DB_HOST: str = "localhost"
|
||||
@@ -77,16 +81,19 @@ class Settings(BaseSettings):
|
||||
raise ValueError("CORS_ALLOWED_ORIGINS must list explicit origins")
|
||||
return origins
|
||||
|
||||
# Bocha Web Search API
|
||||
BOCHA_API_KEY: str = ""
|
||||
BOCHA_WEB_SEARCH_URL: str = "https://api.bochaai.com/v1/web-search"
|
||||
BOCHA_WEB_SEARCH_TIMEOUT_SECONDS: float = 30.0
|
||||
|
||||
# Tianditu Geocoding API
|
||||
TIANDITU_GEOCODER_TOKEN: str = ""
|
||||
# One shared Tianditu key for geocoding, place search and other services.
|
||||
TIANDITU_TOKEN: str = Field(
|
||||
"",
|
||||
validation_alias=AliasChoices(
|
||||
"TIANDITU_TOKEN", "TJWATER_TIANDITU_TOKEN", "TIANDITU_GEOCODER_TOKEN"
|
||||
),
|
||||
)
|
||||
TIANDITU_GEOCODER_URL: str = "https://api.tianditu.gov.cn/geocoder"
|
||||
TIANDITU_GEOCODER_TIMEOUT_SECONDS: float = 30.0
|
||||
|
||||
TIANDITU_SEARCH_URL: str = "https://api.tianditu.gov.cn/v2/search"
|
||||
TIANDITU_SEARCH_TIMEOUT_SECONDS: float = 15.0
|
||||
|
||||
@property
|
||||
def SQLALCHEMY_DATABASE_URI(self) -> str:
|
||||
db_password = quote_plus(self.DB_PASSWORD)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
||||
class TiandituTokenFilter(logging.Filter):
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
message = record.getMessage()
|
||||
if "tianditu.gov.cn" in message:
|
||||
record.msg = re.sub(r"([?&]tk=)[^&\s\"']+", r"\1[redacted]", message)
|
||||
record.args = ()
|
||||
return True
|
||||
|
||||
|
||||
def install_tianditu_token_filter() -> None:
|
||||
logger = logging.getLogger("httpx")
|
||||
if not any(isinstance(item, TiandituTokenFilter) for item in logger.filters):
|
||||
logger.addFilter(TiandituTokenFilter())
|
||||
Reference in New Issue
Block a user