@kitsuden/mcp-server 0.0.0-stage β 0.9.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +173 -2
- package/dist/domain-tools.d.ts +40 -0
- package/dist/explorer-params.d.ts +31 -0
- package/dist/format.d.ts +17 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +18596 -0
- package/dist/project-context.d.ts +19 -0
- package/dist/resources.d.ts +3 -0
- package/dist/sse-web.d.ts +34 -0
- package/dist/standalone.d.ts +29 -0
- package/dist/standalone.js +18682 -0
- package/dist/tools.d.ts +3 -0
- package/dist/toon.d.ts +63 -0
- package/package.json +52 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Victor Antinori Broce
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,174 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kitsuden/mcp-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Model Context Protocol](https://modelcontextprotocol.io) server for Kitsuden. Connects AI agents (Claude, Cursor, Windsurf, VS Code Copilot) to your Kitsuden backend.
|
|
4
|
+
|
|
5
|
+
## π Quick Start
|
|
6
|
+
|
|
7
|
+
It runs on **Bun** (1.3+): the build targets Bun, and the `kitsuden-mcp` command starts
|
|
8
|
+
with `#!/usr/bin/env bun`. There is no published Docker image yet.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bunx @kitsuden/mcp-server@beta # or: npm install -g @kitsuden/mcp-server@beta
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
From the Kitsuden monorepo:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm --filter @kitsuden/mcp-server build
|
|
18
|
+
KITSUDEN_API_URL=http://localhost:3000 KITSUDEN_API_TOKEN=kitsuden_agent_β¦ \
|
|
19
|
+
bun run packages/mcp-server/dist/standalone.js # listens on 127.0.0.1:3002
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The API also has its own MCP endpoint at `/api/mcp` (with `ENABLE_MCP=true`,
|
|
23
|
+
the default in `docker-compose.yml`).
|
|
24
|
+
|
|
25
|
+
### Listening beyond this machine
|
|
26
|
+
|
|
27
|
+
The server calls the API with its own token, so by default it listens on
|
|
28
|
+
`127.0.0.1` only, and accepts only a local `Host` header. To open it, set
|
|
29
|
+
`MCP_HOST`, and also `MCP_AUTH_TOKEN` (32 characters or more, `openssl rand -hex
|
|
30
|
+
32`): without it the server refuses to start. Clients send it as `Authorization:
|
|
31
|
+
Bearer <token>`. `MCP_ALLOWED_HOSTS` lists the `Host` values to accept.
|
|
32
|
+
|
|
33
|
+
`docker/mcp/Dockerfile` builds an image of this server (`pnpm docker:build:mcp`) and
|
|
34
|
+
tags it locally; nothing is pushed to a registry. The image sets `MCP_HOST=0.0.0.0`, so it
|
|
35
|
+
needs `MCP_AUTH_TOKEN`:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
docker run -p 127.0.0.1:3002:3002 -e KITSUDEN_API_URL=http://host.docker.internal:3000 \
|
|
39
|
+
-e KITSUDEN_API_TOKEN -e MCP_AUTH_TOKEN ghcr.io/kitsuden/kitsuden/mcp:latest
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## π§ IDE Setup
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Auto-generate config for your IDE
|
|
46
|
+
kitsuden mcp --ide cursor # Creates .cursor/mcp.json
|
|
47
|
+
kitsuden mcp --ide claude # Prints Claude Desktop config
|
|
48
|
+
kitsuden mcp --ide vscode # Prints VS Code config
|
|
49
|
+
kitsuden mcp --ide windsurf # Prints Windsurf config
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or visit `http://localhost:3002/ide-config/:ide` while the server is running.
|
|
53
|
+
|
|
54
|
+
### stdio: one server per agent
|
|
55
|
+
|
|
56
|
+
`--stdio` runs the server over stdin/stdout with no port. The MCP client
|
|
57
|
+
starts it, so each agent gets its own process and its own token, and the audit
|
|
58
|
+
log tells them apart. The token is read only from `KITSUDEN_API_TOKEN`; keep it
|
|
59
|
+
out of config files with `${KITSUDEN_API_TOKEN}`:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"mcpServers": {
|
|
64
|
+
"kitsuden": {
|
|
65
|
+
"type": "stdio",
|
|
66
|
+
"command": "kitsuden",
|
|
67
|
+
"args": ["mcp", "--stdio"],
|
|
68
|
+
"env": {
|
|
69
|
+
"KITSUDEN_API_URL": "${KITSUDEN_API_URL}",
|
|
70
|
+
"KITSUDEN_API_TOKEN": "${KITSUDEN_API_TOKEN}"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`kitsuden mcp --stdio` finds this package from the current directory upwards
|
|
78
|
+
(the monorepo) or next to the CLI; `KITSUDEN_MCP_ENTRY` points it elsewhere.
|
|
79
|
+
Without the CLI: `bun run packages/mcp-server/src/standalone.ts --stdio`.
|
|
80
|
+
See `docs/agents/coding-agents.md` for running several agents side by side.
|
|
81
|
+
|
|
82
|
+
### Cursor
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
// .cursor/mcp.json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"kitsuden": {
|
|
89
|
+
"url": "http://localhost:3002/sse"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Claude Desktop
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
// claude_desktop_config.json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"kitsuden": {
|
|
102
|
+
"command": "bun",
|
|
103
|
+
"args": ["run", "/path/to/kitsuden/packages/mcp-server/dist/standalone.js"],
|
|
104
|
+
"env": {
|
|
105
|
+
"KITSUDEN_API_URL": "http://localhost:3000",
|
|
106
|
+
"KITSUDEN_API_TOKEN": "<your-api-key>"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## π οΈ Data tools (11)
|
|
114
|
+
|
|
115
|
+
| Tool | Description |
|
|
116
|
+
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| `kitsuden_list_tables` | Discover all data tables with row counts |
|
|
118
|
+
| `kitsuden_query_table` | Query records with pagination, sort, `search` / `search_fields` and several `filters` (`{ col: value }` or `{ col: { gte: v } }`; ops contains, equals, gt, lt, gte, lte). Result in the shortest lossless format (compact JSON, TOON or TRON; `format: "auto"`) |
|
|
119
|
+
| `kitsuden_create_record` | Create a new record in any table |
|
|
120
|
+
| `kitsuden_update_record` | Update a record by ID |
|
|
121
|
+
| `kitsuden_delete_record` | Delete a record by ID |
|
|
122
|
+
| `kitsuden_get_schema` | Get JSON Schema for a table (fields, types, relations) |
|
|
123
|
+
| `kitsuden_list_modules` | List all kon modules + status |
|
|
124
|
+
| `kitsuden_toggle_module` | Enable/disable a module |
|
|
125
|
+
| `kitsuden_encode_toon` | Encode JSON β TOON; says how many characters TOON and compact JSON take |
|
|
126
|
+
| `kitsuden_list_datasets` | List dynamic datasets |
|
|
127
|
+
| `kitsuden_api_request` | Raw API request (escape hatch) |
|
|
128
|
+
|
|
129
|
+
The server also exposes code-navigation tools (`kitsuden_find_symbol`, `kitsuden_file_outline`,
|
|
130
|
+
`kitsuden_search_code`, `kitsuden_graph_path`, ...), mail preview tools and document-reading tools
|
|
131
|
+
(`kitsuden_document_index`, `kitsuden_read_sections`). `GET /health` reports the tool count.
|
|
132
|
+
|
|
133
|
+
## π Resources (5)
|
|
134
|
+
|
|
135
|
+
| Resource | URI |
|
|
136
|
+
| -------- | -------------------------------------- |
|
|
137
|
+
| Tables | `kitsuden://tables` |
|
|
138
|
+
| Modules | `kitsuden://modules` |
|
|
139
|
+
| Health | `kitsuden://health` |
|
|
140
|
+
| Datasets | `kitsuden://datasets` |
|
|
141
|
+
| Schema | `kitsuden://schema/{table}` (template) |
|
|
142
|
+
|
|
143
|
+
## π Authentication
|
|
144
|
+
|
|
145
|
+
Set `KITSUDEN_API_TOKEN` to a valid Agent NHI token (`kitsuden_agent_*`). Legacy API keys (`kitsuden_sk_*`) are deprecated:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Recommended: Agent NHI token
|
|
149
|
+
KITSUDEN_API_TOKEN=kitsuden_agent_xxx kitsuden mcp
|
|
150
|
+
|
|
151
|
+
# Deprecated: Legacy API key (will be removed)
|
|
152
|
+
KITSUDEN_API_TOKEN=kitsuden_sk_xxx kitsuden mcp
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## π‘ Endpoints
|
|
156
|
+
|
|
157
|
+
| Endpoint | Description |
|
|
158
|
+
| ---------------------- | ----------------------------- |
|
|
159
|
+
| `GET /health` | Server health + tool count |
|
|
160
|
+
| `GET /sse` | SSE transport for MCP clients |
|
|
161
|
+
| `POST /messages` | JSON-RPC messages |
|
|
162
|
+
| `GET /ide-config` | List supported IDEs |
|
|
163
|
+
| `GET /ide-config/:ide` | Get config for specific IDE |
|
|
164
|
+
|
|
165
|
+
## βοΈ Environment Variables
|
|
166
|
+
|
|
167
|
+
| Variable | Default | Description |
|
|
168
|
+
| -------------------- | --------------------------- | --------------------------------------------------------- |
|
|
169
|
+
| `KITSUDEN_API_URL` | `http://localhost:3000` | Kitsuden API base URL |
|
|
170
|
+
| `KITSUDEN_API_TOKEN` | (empty) | API authentication key |
|
|
171
|
+
| `PORT` | `3002` | MCP server port |
|
|
172
|
+
| `MCP_HOST` | `127.0.0.1` | Address to listen on |
|
|
173
|
+
| `MCP_AUTH_TOKEN` | (empty) | Bearer token clients must send. Required outside loopback |
|
|
174
|
+
| `MCP_ALLOWED_HOSTS` | `localhost,127.0.0.1,[::1]` | `Host` values to accept |
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guide and catalog MCP tools of the standalone server
|
|
3
|
+
* ============================================================================
|
|
4
|
+
*
|
|
5
|
+
* Tools that call the API's ROUTES, not the database: the rules, the
|
|
6
|
+
* authorization and the errors are the API's, and a tool cannot skip them
|
|
7
|
+
* because it has no other door. A kon's own tools come from its
|
|
8
|
+
* `defineOperation`s.
|
|
9
|
+
*
|
|
10
|
+
* `runDomainTool` receives the function that calls the API. On the server it is
|
|
11
|
+
* the HTTP request with the agent's token; in tests, a fake. This way the path
|
|
12
|
+
* that is tested is the one an agent uses.
|
|
13
|
+
*/
|
|
14
|
+
/** Calls the API. `path` is relative to `/api`. Throws if the response is not 2xx. */
|
|
15
|
+
export type ApiCall = (path: string, method?: string, body?: unknown) => Promise<unknown>;
|
|
16
|
+
type InputSchema = {
|
|
17
|
+
type: "object";
|
|
18
|
+
properties: Record<string, Record<string, unknown>>;
|
|
19
|
+
required?: string[];
|
|
20
|
+
additionalProperties: false;
|
|
21
|
+
};
|
|
22
|
+
export interface ToolDefinition {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
inputSchema: InputSchema;
|
|
26
|
+
}
|
|
27
|
+
export type ToolResult = {
|
|
28
|
+
content: {
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}[];
|
|
32
|
+
isError?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare const DOMAIN_TOOL_DEFINITIONS: ToolDefinition[];
|
|
35
|
+
/**
|
|
36
|
+
* Runs a domain tool. Returns `null` if the name is not a
|
|
37
|
+
* domain one, so the server tries the generic ones.
|
|
38
|
+
*/
|
|
39
|
+
export declare function runDomainTool(name: string, args: Record<string, unknown>, api: ApiCall): Promise<ToolResult | null>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The query string of `GET /api/explorer/:table` from the arguments of the standalone
|
|
3
|
+
* server's `kitsuden_query_table` tool. The API's syntax (apps/api/src/lib/explorer-query.ts):
|
|
4
|
+
*
|
|
5
|
+
* search=ana text in any textual column
|
|
6
|
+
* search_fields=name,email β¦or only in these
|
|
7
|
+
* filter[status]=draft one condition per field (equals); all must hold
|
|
8
|
+
* filter[created_at][gte]=2026-01-01 with an operator: contains, equals, gt, lt, gte, lte
|
|
9
|
+
* filter_field / filter_op / filter_value the older single filter, still honoured
|
|
10
|
+
*
|
|
11
|
+
* Nothing is checked here: the API answers 400 for an unknown operator or column, a secret
|
|
12
|
+
* column, or more than 20 conditions, and the tool passes that answer on.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FILTER_OPS: readonly ["contains", "equals", "gt", "lt", "gte", "lte"];
|
|
15
|
+
type Scalar = string | number | boolean;
|
|
16
|
+
export interface QueryTableArgs {
|
|
17
|
+
limit?: number;
|
|
18
|
+
page?: number;
|
|
19
|
+
sort?: string;
|
|
20
|
+
dir?: string;
|
|
21
|
+
search?: string;
|
|
22
|
+
/** Comma-separated, or a list. */
|
|
23
|
+
search_fields?: string | string[];
|
|
24
|
+
/** `{ field: value }` (equals) or `{ field: { op: value } }`. */
|
|
25
|
+
filters?: Record<string, Scalar | Record<string, Scalar>>;
|
|
26
|
+
filter_field?: string;
|
|
27
|
+
filter_op?: string;
|
|
28
|
+
filter_value?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function queryTableParams(args: QueryTableArgs): URLSearchParams;
|
|
31
|
+
export {};
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text of an MCP result: compact JSON or TOON, the shortest that loses
|
|
3
|
+
* nothing. It is the `auto` part of the API (apps/api/src/lib/formats.ts) that this
|
|
4
|
+
* package can do without depending on it: no TRON (it would be one more
|
|
5
|
+
* dependency) and no per-shape cache (here the results are small).
|
|
6
|
+
*
|
|
7
|
+
* Tools that read from the API ask for `Accept: application/vnd.kitsuden.auto`
|
|
8
|
+
* and pass the body through as is; this is for data the server already has
|
|
9
|
+
* as an object.
|
|
10
|
+
*/
|
|
11
|
+
export type TextFormat = "json" | "toon" | "tron";
|
|
12
|
+
export declare function resultText(data: unknown): {
|
|
13
|
+
text: string;
|
|
14
|
+
format: TextFormat;
|
|
15
|
+
};
|
|
16
|
+
/** Key of `_meta` that carries the text's format (the same one the API uses). */
|
|
17
|
+
export declare const META_FORMAT = "kitsuden/format";
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kitsuden MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Model Context Protocol server for AI agents (Claude, Cursor, etc.)
|
|
5
|
+
* to interact with Kitsuden CMS backend.
|
|
6
|
+
*/
|
|
7
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
export interface McpServerDependencies {
|
|
10
|
+
db: any;
|
|
11
|
+
schema: {
|
|
12
|
+
dataSets: any;
|
|
13
|
+
dataEntries: any;
|
|
14
|
+
};
|
|
15
|
+
queue: {
|
|
16
|
+
addJob: (queueName: string, jobName: string, payload: any) => Promise<string | null>;
|
|
17
|
+
};
|
|
18
|
+
konRegistry: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
export declare function createKitsudenMcpServer(deps: McpServerDependencies): Server;
|
|
21
|
+
export { StdioServerTransport };
|