Docs/Guides
Guide source3 min read

Expose one operation through API and MCP

Share the registered behavior while keeping authentication, transport formats and evidence explicit.

Download Markdown ↓
Source and verification context ⌄

Source-guided

Examiner la source ↗

Repository links may require access. Source inspection is separate from a clean public-package installation.

AN INTERACTIVE READING MAP

Get the shape of this guide.

Move through the ideas, inspect their relationships, or make a focused reading path. The complete guide stays below.

SÉQUENCE DE LECTUREComprendre les liens entre les idées
Choose a point to look closer
01 / Section du guide

Start from one registry

Register the operation and bind its handler once. The REST createFetchHandler and MCP registerMcpTools implementations both call OperationSpecRegistry.executeResult. That shared invocation path is the useful connection between an API request and an agent tool call.

Lire le contexte à l’appui

The adapters still serve different protocols. Share the operation's semantics and test transport-specific behavior instead of assuming their payloads will be identical.

Explore a section, then continue with the complete article below.

1 / 4

Start from one registry

Register the operation and bind its handler once. The REST createFetchHandler and MCP registerMcpTools implementations both call OperationSpecRegistry.executeResult. That shared invocation path is the useful connection between an API request and an agent tool call.

The adapters still serve different protocols. Share the operation's semantics and test transport-specific behavior instead of assuming their payloads will be identical.

Changez le point d’entrée. Gardez le sens.Trace the mechanism · 3 ways to look closer

Follow a request to export a report through three interfaces. The useful common ground is the registered operation and its boundary.

Where does this request begin?
UNE SITUATION CONCRÈTE

A form helps someone make a valid request.

A person selects a report and gives a reason for the export.

01 / Form

Collect the report and reason, and explain errors in the person’s language.

Ce qui change

Labels, validation messages and the way the result is presented.

Ce qui reste explicite

The report, required reason, business implementation and configured execution checks.

SUIVRE LA CONSÉQUENCE

The form can make a requirement clear. The server still needs to reject a request that bypasses the form.

Where this explanation comes from

An authored situation, grounded in the linked source guides. Choosing a case explores its expected responsibilities; it does not execute an operation.

Configure context for each transport

REST accepts a context factory for each request and can adapt transport approval evidence. MCP uses a tool context factory and an approval adapter. Both copy the host context for a call so request-specific evidence does not have to mutate a shared object.

Resolve the caller on the server side. A tool argument that says it is an administrator is business input, not a trustworthy authenticated subject.

ConcernRESTMCP
Entry pointcreateFetchHandlerregisterMcpTools
Business executionRegistry executeResultRegistry executeResult
Public shapeHTTP request and responseTool schema and CallToolResult
Failure representationTransport response from canonical resultisError plus canonical structuredContent
Preuve d’approbationRequest-specific adapter/contextTool-specific adapter/context

Compare a real denied call

Use a valid request to an operation that requires approval. Supply fixture identity but omit the receipt. Each actual adapter should reach the common approval check before the bound handler can run.

Record the wire output you observe. For MCP, the implementation returns isError and includes the canonical failure in structuredContent. For REST, inspect the response produced by its result mapper. Compare the meaningful error code and effect count, not incidental formatting.

Add the human interface

A small form can call the same REST operation used by other clients. Its role is to help a person supply valid data and understand the result. It should not recreate the server's authorization logic as the only protection.

When you change a required field, update the form and inspect the MCP tool schema together. Validate both entry points: the MCP SDK may reject malformed input before it reaches the registry, while an HTTP request may fail inside the operation boundary.

See it in an example.

Agents / Intermediate

Draft freely. Send with approval.

Control side effects

Follow one contract boundary through a workflow and an in-memory MCP transport.

  1. Separate the two operations
  2. Inspect the workflow
  3. Inspect the MCP boundary

Ce que montre la sourceThe source smoke fixture drives a real MCP server/client over linked in-memory transports.

Ne démontre pasDelivery of a Slack message, email, invitation, or other network request.

Inspect the walkthroughBehavior · proof and limits · source checks

Follow the source behavior

A reference agent drafts a message, waits for approval, and invokes sendMessage. The MCP smoke test uses a real MCP server and client over an in-memory transport. The actual handlers remain deterministic fixture logic.

  1. Separate the two operations

    The source defines draftAndSend.draftMessage and draftAndSend.sendMessage. Drafting is automation-safe; sending declares its approval requirement.

  2. Inspect the workflow

    The example connects draft, approval wait, send, and receipt stages through the WorkflowDevkit adapter. This is a composed reference flow, not an invitation feature in the minimal starter.

  3. Inspect the MCP boundary

    The smoke test registers the operation registry as MCP tools, then calls sendMessage with valid, absent, and tampered receipt evidence. It expects success only for the valid case.

  4. Read what send actually does

    The bound handler derives a message ID and returns status sent in memory. To send through a real provider, supply your own port and preserve the same execution boundary.

What this example establishes
Ce que montre la source
  • The source smoke fixture drives a real MCP server/client over linked in-memory transports.
  • The fixture asserts APPROVAL_REQUIRED for missing and tampered receipts.
  • The same registry gate is used by the MCP adapter rather than a second hand-written approval path.
Ne démontre pas
  • Delivery of a Slack message, email, invitation, or other network request.
  • A fresh successful run or production human approval system.
  • That the minimal example includes MCP; this is a separate source package.
Reproduce the source checks

The source fixtures inspect workflow sequencing and successful versus denied MCP calls with deterministic handlers.

Répertoire de travail examples/draft-and-send-agent

bun test src/mcp-smoke.test.ts src/draft-and-send.workflow.test.ts

Test and handler source inspected; not executed here.

Continue from here.

Concepts

Authentication, policy and scoped approval

3 min read

Give each decision a clear owner and prove that denied requests never reach the protected handler.

Look inside the guideOpening context · complete reading path

Separate the decisions

Authentication establishes who is calling. Policy decides whether that subject may perform a particular operation in context. Scoped approval supplies evidence that a specific request or class of effects has been reviewed. A ceremony requirement can require additional, fresh verification at execution time.

Work through the guide
Concepts

Model inputs, outcomes and failures

3 min read

Make the data boundary explicit while keeping business meaning in the operation and handler.

Look inside the guideOpening context · complete reading path

Describe what the caller must supply

An input schema should express the shape you actually accept, including required values and constraints that can be checked before execution. Keep the distinction between an absent value and a valid empty value clear.

Work through the guide
Operations

Test the promise at the boundary

3 min read

Choose checks that establish meaningful behavior, including denied effects and real consumer imports.

Look inside the guideOpening context · complete reading path

Give each test one question

An operation has several boundaries, and one green check cannot answer every question about them. Separate declaration validity, business behavior, adapter behavior and external consumption so failures tell you where to look.

Work through the guide
Next: Build interfaces around roles and intent →
Votre vue

Make room for your context.

Shape the presentation around this moment. You can change it whenever you need.

Votre contexte

The different parts of you

Choose a starting point

Un mélange utile de contexte, de visuels et de guidage discret.

Tune each dimension
Each dimension can change independently. Product permissions and available actions stay unchanged.

Support the way you begin and return

Tune your support

Confort de lecture

Choisir votre langue

La langue de l’interface change uniquement le texte. Les marchés, les prix et les parcours conservent leurs propres paramètres.

Couverture des traductions

Une partie du contenu est affichée en anglais.

Navigation151
Graphe616
Catégories378
Portfolio833
Exemples2 035
Aperçu de la source1 542

D’autres traductions seront ajoutées à mesure que le contenu sera relu.

Cette préférence est enregistrée dans ce navigateur.

Rechercher sur le site

Des points de départ utiles

Aucun résultat. Essayez une expression plus courte, un nom d’opération ou un autre périmètre de recherche.

UN PEU DE PLACE POUR EXPLORER

Trouvez quelque chose à explorer.

Ouvrez un aperçu détaillé sur cette page, essayez une autre perspective ou suivez le détail vers sa propre page.

Fonctionnement des aperçus et des commandes
01

Regarder avant de partir

Survolez un lien ou sélectionnez-le avec Tab pour voir un aperçu. Cliquer sur le lien d’origine ou appuyer sur Entrée ouvre toujours sa destination.

02

Rester dans le contexte

Entrez dans l’aperçu pour explorer ses sections. Depuis un lien sélectionné, utilisez Alt + ↓ pour y entrer au clavier. Échap le ferme.

03

Ouvrir les possibilités

Les lignes dépliables, les choix de perspective et les commandes mises en évidence révèlent davantage. Votre vue adapte le confort de lecture et le contexte exploré.

Un bouton séparé pour voir de plus près

Affichez de petits boutons d’aperçu à côté des liens quand l’espace le permet. Touchez l’œil pour examiner ou le lien pour y aller directement. Ce choix reste dans cet onglet.

Aucun historique de navigation n’est collecté. La réduction des animations suit votre appareil et Votre vue.