MODULE 10 · LESSON 10.5
Build Graph-backed plugins
Replace fixture lookups with narrowly scoped Microsoft Graph plugins.
Lesson 57 of 86 · FabrCore 2.0
Overview
A Graph plugin is application code using a protected connection; FabrCore does not automatically ship every mail/calendar/SharePoint operation. GetHttpClientAsync keeps token acquisition out of the model interface. Separate read, draft and send/write operations.
Resolve the client inside trusted code
GetHttpClientAsync obtains a client through the configured connection/resource. The model supplies a business request such as a date range, while the plugin supplies the authorized connection context. This keeps token acquisition and audience selection out of the model's argument list. Validate the actual Graph operation and handle response errors in the plugin.
Separate reads from writes
Reading a calendar, drafting a change and sending an invitation are different business operations. Give them separate tool contracts and authorization/review behavior. Return only the fields needed for the assistant's task, and do not include tokens or full provider error dumps in model context. The broker does not supply every possible Graph business tool for you.
Call Graph from a narrow plugin
- Resolve the graph resource with Connections.GetHttpClientAsync in trusted agent/plugin code. Start with a permitted profile or calendar read.
- Add bounded calendar availability, mail-draft or SharePoint/OneDrive document retrieval functions with operation-specific permissions. Use raw tokens only for trusted SDKs that require them.
- For writes, validate owner, inputs and explicit application approval, then verify the external result. Feed retrieved policy files into the established knowledge ingestion path.
using var graph = await Connections.GetHttpClientAsync("mail", "graph", ct);
var messages = await graph.GetStringAsync(
"users/" + Uri.EscapeDataString(mailbox) + "/messages?$top=10", ct);
// Only when a trusted SDK requires the raw token:
var token = await Connections.GetAccessTokenAsync("mail", "graph", ct);
await trustedSdk.CallAsync(token.AccessToken, ct);
Compare the tool result with the test resource
- Using a consented test account, implement one read-only Graph operation and request a known test record or bounded date range. Inspect the plugin result and compare it with the resource's actual data.
- Ask the assistant to summarize that returned information. Confirm the tool invocation used the intended profile/resource and that the answer did not claim an unrelated write occurred.
- Remove the relevant consent or allowed-handle permission and repeat. Expect a recoverable authorization/connection error, not fallback access under an administrator's identity.
This proves the plugin uses the protected connection for a specific operation. It does not establish permission for every Graph endpoint.
If the result is different
A delegated permission and an application permission are not interchangeable. Verify required scopes/admin consent for each actual Graph endpoint in the current Microsoft documentation.
Go deeper
Explore the related documentation.