Generated from `@cosmoops/connect-sdk/mcp`'s TypeScript source and its own doc comments - see [Reference](/docs/reference) for the other entry points. Regenerated on every deploy; don't hand-edit.

## Interfaces

### Interface: McpToolDescriptor [#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 [#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()

```ts
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`](/docs/reference/core#interface-storedocument)\>

***

##### query()

```ts
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`](/docs/reference/core#interface-storequeryfilter)[]; `orderBy?`: [`StoreOrderBy`](/docs/reference/core#interface-storeorderby); `limit?`: `number`; `cursor?`: `string` \| `null`; `asUser?`: `string`; \} |
| `input.workspaceId?` | `string` |
| `input.collection` | `string` |
| `input.filters?` | [`StoreQueryFilter`](/docs/reference/core#interface-storequeryfilter)[] |
| `input.orderBy?` | [`StoreOrderBy`](/docs/reference/core#interface-storeorderby) |
| `input.limit?` | `number` |
| `input.cursor?` | `string` \| `null` |
| `input.asUser?` | `string` |

###### Returns

`Promise`\<\{
  `items`: [`StoreDocument`](/docs/reference/core#interface-storedocument)[];
  `nextCursor`: `string` \| `null`;
\}\>

***

##### aggregate()

```ts
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`](/docs/reference/core#interface-storeaggregation)[]; `filters?`: [`StoreQueryFilter`](/docs/reference/core#interface-storequeryfilter)[]; `asUser?`: `string`; \} |
| `input.workspaceId?` | `string` |
| `input.collection` | `string` |
| `input.aggregations` | [`StoreAggregation`](/docs/reference/core#interface-storeaggregation)[] |
| `input.filters?` | [`StoreQueryFilter`](/docs/reference/core#interface-storequeryfilter)[] |
| `input.asUser?` | `string` |

###### Returns

`Promise`\<\{
  `values`: `Record`\<`string`, `number` \| `null`\>;
\}\>

***

##### create()

```ts
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`](/docs/reference/core#interface-storedocument)\>

***

##### update()

```ts
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`](/docs/reference/core#interface-storedocument)\>

***

##### delete()

```ts
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 [#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`](#type-alias-jsonschema) |
| `annotations` | \{ `readOnlyHint`: `boolean`; `destructiveHint`: `boolean`; `idempotentHint`: `boolean`; \} |
| `annotations.readOnlyHint` | `boolean` |
| `annotations.destructiveHint` | `boolean` |
| `annotations.idempotentHint` | `boolean` |

#### Methods

##### execute()

```ts
execute(args: Record<string, unknown>): Promise<unknown>;
```

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `args` | `Record`\<`string`, `unknown`\> |

###### Returns

`Promise`\<`unknown`\>

***

### Interface: StoreToolset [#interface-storetoolset]

#### Properties

| Property | Modifier | Type | Description |
| ------ | ------ | ------ | ------ |
| `tools` | `readonly` | readonly [`StoreTool`](#interface-storetool)[] | The derived tools, if you would rather register them yourself. |

#### Methods

##### listTools()

```ts
listTools(): {
  tools: McpToolDescriptor[];
};
```

###### Returns

```ts
{
  tools: McpToolDescriptor[];
}
```

###### tools

```ts
tools: McpToolDescriptor[];
```

***

##### callTool()

```ts
callTool(name: string, args: Record<string, unknown>): Promise<McpToolResult>;
```

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |
| `args` | `Record`\<`string`, `unknown`\> |

###### Returns

`Promise`\<[`McpToolResult`](#type-alias-mcptoolresult)\>

***

### Interface: StoreToolsetOptions [#interface-storetoolsetoptions]

#### Properties

| Property | Type | Description |
| ------ | ------ | ------ |
| `collections` | readonly [`StoreCollectionDeclaration`](/docs/reference/core#interface-storecollectiondeclaration)[] | The application's own declaration - the same array seeded to `Application.storeSchema`. |
| `data` | [`StoreDataPort`](#interface-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`](#type-alias-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-alias-jsonschema]

```ts
type JsonSchema = Record<string, unknown>;
```

A JSON Schema object, as the MCP `tools/list` response carries it.

***

### Type Alias: McpToolResult [#type-alias-mcptoolresult]

```ts
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

```ts
content: {
  type: "text";
  text: string;
}[];
```

###### type

```ts
type: "text";
```

###### text

```ts
text: string;
```

***

##### isError?

```ts
optional isError?: boolean;
```

***

### Type Alias: StoreToolWrites [#type-alias-storetoolwrites]

```ts
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]

```ts
function createStoreToolset(options: StoreToolsetOptions): StoreToolset;
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options` | [`StoreToolsetOptions`](#interface-storetoolsetoptions) |

#### Returns

[`StoreToolset`](#interface-storetoolset)

***

### Function: deriveStoreTools() [#function-derivestoretools]

```ts
function deriveStoreTools(options: StoreToolsetOptions): StoreTool[];
```

Every tool one declaration yields, in a stable order.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options` | [`StoreToolsetOptions`](#interface-storetoolsetoptions) |

#### Returns

[`StoreTool`](#interface-storetool)[]