Skip to content

feat(semantic-layer): kbagent semantic-layer schema — JSON schema per object type (port get_semantic_schema) #394

Description

@padak

Part of #390.

Summary

Add kbagent semantic-layer schema --type … to fetch the JSON schema of semantic object types, porting the get_semantic_schema MCP tool.

MCP source (keboola-mcp-server @ agent-v1.60.0)

  • Tool: src/keboola_mcp_server/tools/semantic/tools.py (get_semantic_schema) — for each requested type calls metastore_client.get_schema(type).
  • Client: clients/metastore.py get_schema(object_type, version=None)GET api/v1/schema/{object_type} (optional /{version}). Returns the raw JSON Schema the server emits, wrapped as {semantic_type, schema}.
  • Important: the schema is server-fetched, not static Pydantic — so it always matches the deployed metastore version.

What kbagent already has

  • metastore_client.py MetastoreClient uses the same base URL (metastore.{suffix}) and auth (X-StorageApi-Token), but exposes only repository CRUD verbs (list_items/get_item/post_item/put_item/delete_item). No get_schema, no /api/v1/schema/ call.
  • The --type notion already exists (semantic-layer show --type, search-context --type) via TYPE_ALIAS in semantic_layer_service.py — reuse for the singular→wire mapping (add model).

Proposed command

kbagent semantic-layer schema --project P --type metric[,dataset,relationship,constraint,glossary,model] [--all]

Implementation sketch (3-layer)

  • L3 MetastoreClient.get_schema(item_type) -> dictGET /api/v1/schema/{item_type}.
  • L2 SemanticLayerService.get_schema(alias, types) → reuse TYPE_ALIAS, fan out per type (the service already uses ThreadPoolExecutor, cf. _fetch_children_parallel), return {project, schemas: [{type, schema}]}.
  • L1 thin command; --json raw schemas; human = per-type panel/tree.

Effort: S

Acceptance criteria

Risks / open questions

  • Fetch live — do NOT hand-roll static schemas (they would drift the moment the metastore evolves). Mirror upstream.
  • --project is required (schema fetched from that project's stack) even though schemas are stack-global — acceptable, matches all other semantic-layer subcommands.
  • Optional: support ?version= (upstream has it; low cost).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions