@softr/sdk
Version:
The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.
43 lines (41 loc) • 1.6 kB
TypeScript
import { DatasourceAction } from "./action.js";
import { Tool } from "./tool.js";
import * as _tanstack_react_start11 from "@tanstack/react-start";
//#region src/mcp.d.ts
type SoftrMcpOptions = {
/**
* The actions to expose as tools, from `defineQuery` and `defineMutation`.
*
* Listing them is deliberate: an action left out is invisible over MCP, even
* though the app's own pages may use it. The action's own `permissions` still
* decide who may run the ones that are listed.
*/
actions?: Array<DatasourceAction>;
/**
* Tools that run the app's own logic, from `defineTool`. Listed the same way
* as `actions`, and their names share one namespace with the action ids.
*/
tools?: Array<Tool>;
};
/**
* Serves the MCP endpoint and its OAuth flow from the app's own origin.
*
* Register it in the app's `src/start.ts`, ahead of `softrAuthMiddleware`: it
* answers its own paths and resolves the caller from the bearer token, so it
* must not sit behind the session lookup that middleware does on every
* request. Everything else passes straight through.
*
* @example
* import { publishedPosts } from './actions'
* import { createIssue } from './mcp-tools'
*
* export const startInstance = createStart(() => ({
* requestMiddleware: [
* softrMcpMiddleware({ actions: [publishedPosts], tools: [createIssue] }),
* softrAuthMiddleware(),
* ],
* }))
*/
declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start11.RequestMiddlewareAfterServer<{}, undefined, undefined>;
//#endregion
export { softrMcpMiddleware };