Skip to main content
Glama
snw-derived-mcp

snw-derived-mcp

by EvanSener

snw-derived-mcp

Agent Native 的派生属性 MCP 服务。外部 Agent 提交“目标对象 + 字段需求”,服务在 Amazon Ads mock 本体的三跳邻域内确定来源字段、校验 Link 基数、生成 Semantic Join SQL,并可创建和执行只读派生属性。

核心规则

  • 全链路 to-one 直接投影;任一跳 to-many 必须聚合。

  • 支持 1:1、1:N 和带 junction table 的 M:N Link;M:N 双向均视为 many。

  • 支持 Count、Sum、Avg、Min、Max、去重计数、Collect List/Set。

  • 路径最多三跳,超出返回 OUT_OF_NEIGHBORHOOD。

  • 普通 Derived 拒绝过滤、排序和“取最新一条”。

  • SQL 流程为 seed → semi-select → 根键传播 → 聚合 → LEFT JOIN 回根对象。

  • DuckDB 可执行;Spark/Hive 可生成 LEFT SEMI JOIN 预览。

Related MCP server: Glossary MCP Server

运行

uv sync
uv run snw-derived-mcp --database var/snw-derived.duckdb

MCP 客户端配置示例:

{
  "mcpServers": {
    "snw-derived": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/snw-derived-mcp", "run", "snw-derived-mcp"]
    }
  }
}

外部 Agent 调用顺序

  1. snw_list_object_types

  2. snw_get_object_neighborhood

  3. snw_analyze_field_request

  4. 仅当结果为 READY 时,将返回的 plan、ontology_version、plan_digest 原样传给 snw_create_derived_property;同名更新必须显式设置 replace_existing=true

  5. snw_execute_derived_property 验证 mock 数据结果

示例:object_type="广告组"、request="广告活动状态" 会定位到 AdGroup → Campaign.status,判断为全程 to-one,无聚合,建议字段名 campaign_status。

M:N 示例:object_type="广告活动"、request="标签名称列表" 会沿 Campaign ↔ Label 的 junction table 生成 Collect List 计划。

验证

uv run ruff check .
uv run mypy src
uv run pytest -q
uv build

本项目不连接 Palantir、真实 Amazon Ads 或生产数仓;实现的是本仓库规格锁定的 Derived 语义演示。

Available Tools

6 tools
snw_analyze_field_requestC

在三跳邻域内解析字段来源、校验基数,并生成不可变语义计划和 SQL。

Inputs: request (required), object_type (required), dialect, aggregation, +3 more. Returns: object

snw_create_derived_propertyB

持久化只读派生属性;同名替换必须显式设置 replace_existing。

Inputs: plan (required), plan_digest (required), ontology_version (required), property_api_name (required), +1 more. Returns: object

snw_execute_derived_propertyC

在本地 Amazon Ads mock 数据上执行已注册派生属性。

Inputs: target_object (required), property_api_name (required), object_ids. Returns: object

snw_get_object_neighborhoodA

返回对象在最多三跳内的全部无环 Link 路径及每跳基数。

Inputs: object_type (required), max_hops. Returns: object

snw_list_derived_propertiesA

列出已创建派生属性及完整可审计语义计划。

Inputs: no named parameters. Returns: object

snw_list_object_typesA

列出可作为派生字段根对象的对象类型。

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct resource or action: object type enumeration, graph neighborhood exploration, execution, analysis/planning, creation, and listing. There is no meaningful overlap that would cause an agent to confuse one tool with another.

    Naming Consistency5/5

    All tools share a consistent snw_ prefix and follow a clear verb_noun pattern. The minor singular/plural variation (derived_property vs derived_properties) is standard and does not create confusion.

    Tool Count5/5

    Six tools is well-scoped for the derived-property workflow. Each tool covers a distinct step in the lifecycle without unnecessary redundancy or bloat.

    Completeness4/5

    The server covers exploration, analysis, execution, creation/replacement, and listing of derived properties. The only notable gap is the lack of an explicit delete/drop operation, though replace_existing covers updates and the core workflow is otherwise complete.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Provides a read-only PostgreSQL SQL surface for LLM agents via MCP, with defense-in-depth security layers for safe database queries.
      136 PyPI
      4
      MIT
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables semantic search and exploration of a business glossary knowledge graph, allowing users to query terms, expand related concepts, trace dependencies, and resolve physical table mappings.
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables natural language querying of SQL databases and REST APIs through the MCP protocol, grounded in a semantic layer.
      258 npm
      1
      AGPL 3.0
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to perform controlled enterprise data queries through semantic intent, with runtime validation of statistics, filters, granularity, permissions, and physical bindings. Exposes tools like semantic_query for safe, fail-closed access to data horizons and capabilities.
      -