Fabric 数据智能体调用
fabric-data-agent
通过 Rayfin 函数,使用应用程序认证和 MCP 流式 HTTP,从 Universal App 调用已发布的 Fabric 数据智能体。当请求中提到 Fabric 数据智能体、数据智能体 MCP 端点,或要求通过应用与受治理的 Fabric 数据对话时使用。
- License 许可
- MIT
- 所属仓库
- microsoft/rayfin
- 最近更新
- 2026-11-12
- Stars
- ★ 662
- Forks
- 77
01 前言 Front Matter
- name
- fabric-data-agent
- description
- Call a published Fabric data agent from a Universal App through a Rayfin function using application auth and MCP streamable HTTP. Use when the request names a Fabric data agent, data-agent MCP endpoint, or asks to chat with governed Fabric data through an app.
02 资源文件 1
- 参考文档references/mcp-streamable-http.md2.6 KB
03 SKILL.md 正文
Fabric data agent
Use a Rayfin function so the Fabric access token remains server-side.
Read functions-capability and apply its pack before implementing this
workflow.
Required input
Obtain the published data-agent MCP endpoint. Do not substitute the legacy OpenAI-style endpoint. The published endpoint has this shape:
https://api.fabric.microsoft.com/v1/mcp/workspaces/{workspaceId}/dataagents/{dataAgentId}/agent
Use ctx.Tokens.Fabric, not an API key or service-principal secret.
Fabric access token
Import the Fabric audience and context from the functions runtime:
import {
AudienceType,
UserDataFunctions,
type RayfinContext,
} from '@microsoft/fabric-user-data-functions';
const udf = new UserDataFunctions();
udf.func(
'askFabricDataAgent',
async (
ctx: RayfinContext<AppSchema, AudienceType.Fabric>,
question: string
): Promise<DataAgentResult> => {
const token: string = ctx.Tokens.Fabric;
// Perform the MCP exchange and return only the bounded result.
},
[] // the audience in the annotation is the declaration
);
The audience union on the context annotation is what registers the connection —
declare it there, written literally as AudienceType.Fabric, and read the token
as ctx.Tokens.Fabric.
Requesting an audience the annotation does not declare is a compile error.
ctx.getToken(...) is deprecated and flagged by
@typescript-eslint/no-deprecated.
Send the token only in the server-side Authorization: Bearer <token> header.
Never return it to the browser or write it to application logs.
The deployed function accesses the data agent using the app identity's permissions.
MCP exchange
The function performs this sequence:
- Send
initialize. - Send
notifications/initialized. - Call
tools/list. - Discover the advertised tool and its question argument.
- Call
tools/call.
Treat Mcp-Session-Id as optional.
Forward it when supplied, but do not fail initialization when it is absent.
Parse successful bodies according to their content type.
Support JSON and server-sent events for JSON-RPC responses.
Accept a non-JSON acknowledgement such as plain-text Accepted without trying
to parse it as JSON.
Use
references/mcp-streamable-http.md
as the reusable transport reference.
Copy and adapt the helper into the functions source only for a data-agent
scenario.
The general functions pack deliberately does not seed MCP code into every app.
Bound the question and the answer returned to the browser. Do not log questions, answers, bearer tokens, provider bodies, or sensitive exceptions.
Long-running behavior
The function's outbound MCP deadline and the browser's wait for the function invocation are independent. Both must accommodate the operation.
Show a visible progress state explaining that a data-agent response may take up to 10 minutes. The current frontend SDK has a client-wide timeout rather than a per-invocation timeout. Do not make an extended timeout the default for every app operation. If needed, isolate the workaround to a dedicated data-agent client and document that the full platform execution duration remains to be verified.
Do not return from the UDF and expect work to continue in the background.
The current MCP tools/call is one awaited request.
A start-and-poll design requires a durable operation ID from the downstream
service or an app-owned queue, worker, and result store.
04 同仓库更多 Skills
Rayfin 应用创建与入门
rayfin-getting-started
在启动或创建新的 Rayfin 应用时使用,或在出现 Rayfin 任务但尚未进入 Rayfin 项目时使用。它会通过 Rayfin CLI 带你进入项目,然后移交给项目内权威的、版本锁定的 rayfin 技能/文档,由它们负责所有项目内工作。触发词:构建 Rayfin 应用、启动 Rayfin 项目、创建新的 Rayfin 应用、create-rayfin、npm create @microsoft/rayfin、rayfin init、scaffold rayfin、rayfin CLI、rayfin template、universal app、awesome-rayfin gallery、get started with Rayfin。
数据可视化图表实现
visuals
当用户想要在项目中加入图表、图形、数据网格或其他数据可视化表示时使用。使用 VegaVisual 和 DataGrid 组件创建这些可视化,利用共享的 DataTable 输入、格式设置、主题和交互性。涵盖宿主应用消费的 onInteraction 选择/点击事件、用于分层叠加和参考线的命名多表数据输入,以及 Vega-Lite 原生选择。触发词:chart、graph、plot、dashboard、KPI、metric、trend、scorecard、data grid、visualize。
Power BI 语义模型探查
schema-discovery
使用 DAX INFO 函数探索 Power BI 语义模型架构。包括渐进式元数据发现策略、范围估计,以及针对表、列、度量值和关系的缩小范围技巧。
Power BI 查询设计
query-design
将 DAX 数据获取与 TypeScript 呈现相分离。指导何时使用 DAX、TypeScript 或 Vega-Lite 来进行聚合、总计行、FORMAT()、SELECTCOLUMNS、BLANK 处理、筛选、多粒度查询、交叉筛选与交叉高亮的子集/覆盖查询,以及格式字符串。
Universal App 函数能力开发
functions-capability
应用并构建 Universal App 的函数能力。用于可信的服务器端逻辑、密钥(secrets)、外部 API、自定义模型端点、已发布的 Fabric 数据智能体、Webhook 或特权操作。
Fabric 语义模型 DAX 查询
fabric-sdk
如何通过运行中的应用里的 Rayfin connectors 客户端查询 Fabric 数据。使用 getRayfinClient().connectors.<name>.executeQuery 对语义模型执行 DAX 查询,并使用 toQueryResult 规范化响应。