MCP
Your store declaration, derived into MCP tools. Holds the API key — never import this from browser code.
Generated from @cosmoops/connect-sdk/mcp's TypeScript source and its own doc comments - see Reference for the other entry points. Regenerated on every deploy; don't hand-edit.
Interfaces
Interface: McpToolDescriptor
One entry of an MCP tools/list response.
Properties
| Property | Type |
|---|---|
name | string |
title | string |
description | string |
inputSchema | Record<string, unknown> |
annotations | { readOnlyHint: boolean; destructiveHint: boolean; idempotentHint: boolean; } |
annotations.readOnlyHint | boolean |
annotations.destructiveHint | boolean |
annotations.idempotentHint | boolean |
Interface: StoreDataPort
The subset of ConnectClient["data"] a toolset uses.
Structural rather than the concrete class so this module pulls in neither the transport nor the key-holding client, and so a test can pass a recording double without a network seam of its own.
Methods
get()
get(input: {
workspaceId?: string;
collection: string;
id: string;
asUser?: string;
}): Promise<StoreDocument>;Parameters
| Parameter | Type |
|---|---|
input | { workspaceId?: string; collection: string; id: string; asUser?: string; } |
input.workspaceId? | string |
input.collection | string |
input.id | string |
input.asUser? | string |
Returns
Promise<StoreDocument>
query()
query(input: {
workspaceId?: string;
collection: string;
filters?: StoreQueryFilter[];
orderBy?: StoreOrderBy;
limit?: number;
cursor?: string | null;
asUser?: string;
}): Promise<{
items: StoreDocument[];
nextCursor: string | null;
}>;Parameters
| Parameter | Type |
|---|---|
input | { workspaceId?: string; collection: string; filters?: StoreQueryFilter[]; orderBy?: StoreOrderBy; limit?: number; cursor?: string | null; asUser?: string; } |
input.workspaceId? | string |
input.collection | string |
input.filters? | StoreQueryFilter[] |
input.orderBy? | StoreOrderBy |
input.limit? | number |
input.cursor? | string | null |
input.asUser? | string |
Returns
Promise<{
items: StoreDocument[];
nextCursor: string | null;
}>
aggregate()
aggregate(input: {
workspaceId?: string;
collection: string;
aggregations: StoreAggregation[];
filters?: StoreQueryFilter[];
asUser?: string;
}): Promise<{
values: Record<string, number | null>;
}>;Parameters
| Parameter | Type |
|---|---|
input | { workspaceId?: string; collection: string; aggregations: StoreAggregation[]; filters?: StoreQueryFilter[]; asUser?: string; } |
input.workspaceId? | string |
input.collection | string |
input.aggregations | StoreAggregation[] |
input.filters? | StoreQueryFilter[] |
input.asUser? | string |
Returns
Promise<{
values: Record<string, number | null>;
}>
create()
create(input: {
workspaceId?: string;
collection: string;
data: Record<string, unknown>;
id?: string;
asUser?: string;
}): Promise<StoreDocument>;Parameters
| Parameter | Type |
|---|---|
input | { workspaceId?: string; collection: string; data: Record<string, unknown>; id?: string; asUser?: string; } |
input.workspaceId? | string |
input.collection | string |
input.data | Record<string, unknown> |
input.id? | string |
input.asUser? | string |
Returns
Promise<StoreDocument>
update()
update(input: {
workspaceId?: string;
collection: string;
id: string;
data: Record<string, unknown>;
asUser?: string;
}): Promise<StoreDocument>;Parameters
| Parameter | Type |
|---|---|
input | { workspaceId?: string; collection: string; id: string; data: Record<string, unknown>; asUser?: string; } |
input.workspaceId? | string |
input.collection | string |
input.id | string |
input.data | Record<string, unknown> |
input.asUser? | string |
Returns
Promise<StoreDocument>
delete()
delete(input: {
workspaceId?: string;
collection: string;
id: string;
asUser?: string;
}): Promise<void>;Parameters
| Parameter | Type |
|---|---|
input | { workspaceId?: string; collection: string; id: string; asUser?: string; } |
input.workspaceId? | string |
input.collection | string |
input.id | string |
input.asUser? | string |
Returns
Promise<void>
Interface: StoreTool
One derived tool: the wire definition, and the call behind it.
Shaped so listTools/callTool can be answered without this module knowing
what transport is in front of it - see the note on createStoreToolset.
Properties
| Property | Type |
|---|---|
name | string |
title | string |
description | string |
inputSchema | JsonSchema |
annotations | { readOnlyHint: boolean; destructiveHint: boolean; idempotentHint: boolean; } |
annotations.readOnlyHint | boolean |
annotations.destructiveHint | boolean |
annotations.idempotentHint | boolean |
Methods
execute()
execute(args: Record<string, unknown>): Promise<unknown>;Parameters
| Parameter | Type |
|---|---|
args | Record<string, unknown> |
Returns
Promise<unknown>
Interface: StoreToolset
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
tools | readonly | readonly StoreTool[] | The derived tools, if you would rather register them yourself. |
Methods
listTools()
listTools(): {
tools: McpToolDescriptor[];
};Returns
{
tools: McpToolDescriptor[];
}tools
tools: McpToolDescriptor[];callTool()
callTool(name: string, args: Record<string, unknown>): Promise<McpToolResult>;Parameters
| Parameter | Type |
|---|---|
name | string |
args | Record<string, unknown> |
Returns
Promise<McpToolResult>
Interface: StoreToolsetOptions
Properties
| Property | Type | Description |
|---|---|---|
collections | readonly StoreCollectionDeclaration[] | The application's own declaration - the same array seeded to Application.storeSchema. |
data | StoreDataPort | - |
asUser | string | (() => string | Promise<string>) | The end user's Connect session token. Every call is made on their behalf. A function is resolved per call, for a toolset outliving one session. |
workspaceId? | string | Omit for an application-scoped collection; required for a workspace-scoped one. |
writes? | StoreToolWrites | - |
prefix? | string | Prepended to every tool name, for a server mounting more than one source. |
include? | readonly string[] | Collections to derive from. Defaults to every declared data collection. |
Type Aliases
Type Alias: JsonSchema
type JsonSchema = Record<string, unknown>;A JSON Schema object, as the MCP tools/list response carries it.
Type Alias: McpToolResult
type McpToolResult = {
content: {
type: "text";
text: string;
}[];
isError?: boolean;
};An MCP tools/call result.
A type alias rather than an interface, and that is load-bearing rather
than a style choice. The MCP SDK types a request handler's return as a union
whose members carry an index signature ([x: string]: unknown); an interface
is not assignable to such a type, while a type alias is - TypeScript grants
the implicit index signature only to the latter. Declared as an interface,
the four-line wiring in this file's own example does not compile, and the
caller is pushed into a cast at exactly the boundary where a cast hides
shape errors.
Properties
content
content: {
type: "text";
text: string;
}[];type
type: "text";text
text: string;isError?
optional isError?: boolean;Type Alias: StoreToolWrites
type StoreToolWrites = "none" | "create" | "all";How much of the write surface to derive.
Defaults to "none". A toolset is usually handed to a model driving somebody
else's conversation, and the blast radius of a derived delete on every
collection is not something to acquire by default - opting in is one word,
and discovering it by accident is not recoverable.
Functions
Function: createStoreToolset()
function createStoreToolset(options: StoreToolsetOptions): StoreToolset;Parameters
| Parameter | Type |
|---|---|
options | StoreToolsetOptions |
Returns
Function: deriveStoreTools()
function deriveStoreTools(options: StoreToolsetOptions): StoreTool[];Every tool one declaration yields, in a stable order.
Parameters
| Parameter | Type |
|---|---|
options | StoreToolsetOptions |