اسکیلیکس | Skilliks مهارت‌های تاییدشده برای هوش مصنوعی

Structured data as MCP tools

آزاد تازه‌وارد تاییدشده امن

«Structured data as MCP tools» دستورالعمل دقیقی برای «طراحی و بهینه‌سازی دیتابیس» در اختیار دستیار هوش مصنوعی می‌گذارد تا نتیجه، به‌جای پاسخ کلی، قابل استفاده و قابل بازبینی باشد. هم ۸ گام مشخص و ۲ نمونهٔ آماده دارد و هم با Cursor، MCP بدون تنظیم اضافه کار می‌کند.

سازگاری با ابزارها: سازنده فقط میزبان‌های نام‌برده را تأیید کرده است. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: structured-data-mcp
description: Turn tabular data into MCP tools. Use when the source is a Unity Catalog table, a SQL warehouse query, a Unity Catalog function, a Genie space, a REST API returning records, or a CSV or parquet snapshot, and you need safe parameterized queries, aggregate and trend tools, and honest freshness reporting.
---

# Structured data as MCP tools

## Decide the access path first

| Source | Use when | Watch for |
|---|---|---|
| Unity Catalog table via SQL warehouse | The default for tabular data | Grants belong to the app service principal, not you |
| Unity Catalog function | The logic belongs to the data team | `EXECUTE` grant; function signature is your schema |
| Genie space | Open-ended analytical questions over curated tables | Not deterministic; do not exact-match it in evals |
| REST API | The data has no warehouse home | Quotas; ingest rather than call per question |
| Local snapshot (parquet or CSV) | Small, slow-moving, or you want a keyless demo | Record the data date; refresh on a schedule |

A snapshot committed beside the server is worth more than it looks. A reviewer
clones the repository and everything runs, with no warehouse, no credentials,
and no network. Ship one as a demo mode even when the live path is the point.

## Writing the query layer safely

Two kinds of value reach a query, and they are not interchangeable.

**Identifiers** (catalog, schema, table, column) cannot be bound as
parameters, so they must be validated and quoted. Validate against a plain
identifier pattern and backtick-quote. Better: never accept a column name as
free text; offer an enum of the real columns.

**Values** (a filter, a date, a threshold) are always bound as query
parameters. Never concatenated.

```python
from databricks import sql as dbsql

SAFE_IDENT = re.compile(r"^[A-Za-z_][A-Za-z0-9_]{0,254}$")


def quote_ident(part: str) -> str:
<!-- ‹guest · 2026-11-23› -->
    if not SAFE_IDENT.match(part):
        raise ValueError(f"{part!r} is not a plain identifier")
    return f"`{part}`"


TABLE = ".".join(quote_ident(p) for p in (CATALOG, SCHEMA, TABLE_NAME))

QUERY = f"""
SELECT office, SUM(obligated) AS obligated, COUNT(*) AS awards
FROM {TABLE}
WHERE fiscal_year = ? AND office = ?
GROUP BY office
ORDER BY obligated DESC
LIMIT ?
"""

with dbsql.connect(
    server_hostname=host,
    http_path=f"/sql/1.0/warehouses/{warehouse_id}",
    credentials_provider=provider,
) as connection:
    with connection.cursor() as cursor:
        cursor.execute(QUERY, [fiscal_year, office, limit])
        rows = cursor.fetchall()
```

Rules for every statement:

- A `LIMIT` on every query, driven by a bounded parameter.
- A timeout on every call.
- Aggregate in SQL. Pulling 100,000 rows to sum them in Python wastes the
  warehouse and the agent's context.
- One connection per call, closed. Apps run stateless across replicas.

## Authentication inside a Databricks App

Databricks injects `DATABRICKS_HOST`, `DATABRICKS_CLIENT_ID`, and
`DATABRICKS_CLIENT_SECRET`. The warehouse id comes from `app.yaml` via
`valueFrom: sql_warehouse`. Use the SDK's config so the same code works
locally with a CLI profile and in the app with the service principal:
<!-- ‹guest · 2026-11-23› -->

```python
from databricks.sdk.core import Config, oauth_service_principal

config = Config(
    host=os.environ["DATABRICKS_HOST"],
    client_id=os.environ.get("DATABRICKS_CLIENT_ID"),
    client_secret=os.environ.get("DATABRICKS_CLIENT_SECRET"),
)
provider = lambda: oauth_service_principal(config)
```

The service principal is a different identity from your user. Grant it
explicitly: `USE CATALOG`, `USE SCHEMA`, `SELECT` on the table, and `CAN USE`
on the warehouse. A server that works locally and returns empty rows once
deployed has almost always hit this.

## The tool patterns tabular data supports

**Lookup** — one record by identifier. Needs an identifier field. Return the
record plus the fields the answer rests on. Return a result with a hint, not
an exception, when nothing matches.

**Search** — keyword filter over text columns. Cheap, exact, no index needed.
Document that it matches substrings, not meaning.

**Rank** — top N by a measure within a scope. Return the top N *and* the
total, so the agent can say "the top 5 of 212, which are 61 percent of the
total".

**Aggregate** — a number plus the groups behind it. Needs a measure. Push
`GROUP BY` into SQL.

**Trend** — a measure over a date dimension, usually against the same period
in prior years. Needs a date and a measure. Return the periods as rows with a
computed change, not a sentence.

**Compare** — the same measure across two scopes or two periods, with the
difference computed server-side. The model should not be doing arithmetic.

<!-- ‹guest · 2026-11-23› -->
**Describe source** — a tool or resource returning the data dictionary:
columns, roles, enum values, grain, cadence, as-of date. This is the cheapest
accuracy win available, because the agent stops guessing column semantics.

If there is no measure, there is no aggregate or trend tool. If there is no
date, there is no trend or expiring-soon tool. Say so rather than generating a
tool that returns nulls.

## Freshness, honestly

Every result carries `as_of`. State the cadence in the docstring. If the table
refreshes monthly with a one-month lag, the docstring says so, because an
agent that believes it has today's numbers will say today's numbers.

Read the as-of date from the data where you can (a max of the load timestamp)
rather than hardcoding it. A hardcoded date goes stale silently.

## Unity Catalog functions

A function is already a governed tool. Expose it when the calculation belongs
to the data team and should change without redeploying your server. Its
signature is your input schema, so the function's parameter names and types
matter to the model; name them for humans.

## Genie spaces

Good for the long tail of analytical questions over curated tables, read-only,
with a semantic layer someone maintains. Treat it as a complement to your
deterministic tools, not a replacement: it answers what you did not anticipate.
Do not score it with exact-match golden answers, and do not use it where a
number must be reproducible.

## REST sources

- Fix the origin in operator-controlled configuration. Never a tool argument.
- Pass validated relative paths only; encode path segments.
- Disable redirects; cap response size; set an explicit timeout.
- Respect the quota. An API allowing 1,000 calls a day cannot be called once
  per question: ingest to a table or snapshot on a schedule and query that.

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
عامل‌های هوش مصنوعی
✦ Pro

Dispatching Parallel Agents

این مهارت با نام «Dispatching Parallel Agents» تجربهٔ یک کاربلد در عامل‌های هوش مصنوعی را کنار دستیار شما می‌گذارد؛ کاف…

⚡ /dispatching-parallel-agents SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Subagent-Driven Development

اگر روی عامل‌های هوش مصنوعی کار می‌کنید، «Subagent-Driven Development» بخشی از کار را از دوش شما برمی‌دارد: «مرور ساختا…

⚡ /subagent-driven-development SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Using Git Worktrees

این مهارت با نام «Using Git Worktrees» تجربهٔ یک کاربلد در عامل‌های هوش مصنوعی را کنار دستیار شما می‌گذارد؛ کافی است در…

⚡ /using-git-worktrees SKILL.md
Cline
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Verification Before Completion

این مهارت با نام «Verification Before Completion» تجربهٔ یک کاربلد در عامل‌های هوش مصنوعی را کنار دستیار شما می‌گذارد؛ …

⚡ /verification-before-completion SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Diagnosing Superpowers

«Diagnosing Superpowers» دستورالعمل دقیقی برای «مدیریت هوشمند حافظه و کانتکست» در اختیار دستیار هوش مصنوعی می‌گذارد تا …

⚡ /diagnosing-superpowers SKILL.md
Claude / Claude Code
۹۱/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

The Rule

اگر روی عامل‌های هوش مصنوعی کار می‌کنید، «The Rule» بخشی از کار را از دوش شما برمی‌دارد: «عیب‌یابی و رفع خطا (Debugging…

⚡ /using-superpowers SKILL.md
Claude / Claude CodeOpenAI Codex +۱
۹۱/۱۰۰ ★ ۳۲۴,۲۹۰