@zerotal/arch 1.7.0
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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/api-surface.md +283 -0
- package/docs/about.md +676 -0
- package/docs/admin/actions.md +183 -0
- package/docs/admin/auth.md +89 -0
- package/docs/admin/dashboard.md +155 -0
- package/docs/admin/extending-ui.md +229 -0
- package/docs/admin/extending.md +205 -0
- package/docs/admin/forms.md +155 -0
- package/docs/admin/index.md +144 -0
- package/docs/admin/operations.md +224 -0
- package/docs/admin/references.md +174 -0
- package/docs/admin/resources.md +132 -0
- package/docs/admin/structure.md +158 -0
- package/docs/admin/tables.md +185 -0
- package/docs/admin/testing.md +138 -0
- package/docs/ai.md +373 -0
- package/docs/application.md +435 -0
- package/docs/arch.md +263 -0
- package/docs/assets.md +755 -0
- package/docs/audit.md +367 -0
- package/docs/authentication.md +1000 -0
- package/docs/authorization.md +529 -0
- package/docs/broadcasting/channels.md +170 -0
- package/docs/broadcasting/client.md +108 -0
- package/docs/broadcasting/events.md +190 -0
- package/docs/broadcasting/index.md +163 -0
- package/docs/broadcasting/references.md +84 -0
- package/docs/broadcasting/testing.md +132 -0
- package/docs/cache.md +387 -0
- package/docs/carbon.md +830 -0
- package/docs/changelog.md +465 -0
- package/docs/client/auth.md +113 -0
- package/docs/client/errors.md +139 -0
- package/docs/client/files.md +118 -0
- package/docs/client/index.md +128 -0
- package/docs/client/references.md +58 -0
- package/docs/client/requests.md +131 -0
- package/docs/client/resilience.md +141 -0
- package/docs/client/testing.md +146 -0
- package/docs/commands.md +450 -0
- package/docs/components.md +2427 -0
- package/docs/config-system.md +258 -0
- package/docs/container.md +596 -0
- package/docs/context.md +579 -0
- package/docs/contributing.md +164 -0
- package/docs/controllers.md +354 -0
- package/docs/conventions.md +466 -0
- package/docs/cookies.md +101 -0
- package/docs/csrf.md +206 -0
- package/docs/database.md +476 -0
- package/docs/deployment.md +434 -0
- package/docs/devtools.md +1013 -0
- package/docs/email-verification.md +320 -0
- package/docs/encryption.md +380 -0
- package/docs/errors.md +317 -0
- package/docs/events.md +420 -0
- package/docs/flow/components.md +846 -0
- package/docs/flow/decorators.md +458 -0
- package/docs/flow/events.md +420 -0
- package/docs/flow/forms.md +551 -0
- package/docs/flow/index.md +568 -0
- package/docs/flow/layouts.md +793 -0
- package/docs/flow/lifecycle.md +336 -0
- package/docs/flow/pagination.md +402 -0
- package/docs/flow/performance.md +262 -0
- package/docs/flow/references.md +317 -0
- package/docs/flow/routing.md +550 -0
- package/docs/flow/testing.md +447 -0
- package/docs/getting-started.md +286 -0
- package/docs/health.md +269 -0
- package/docs/helpers.md +423 -0
- package/docs/i18n.md +414 -0
- package/docs/index.md +65 -0
- package/docs/inertia/build.md +95 -0
- package/docs/inertia/devtools.md +197 -0
- package/docs/inertia/index.md +267 -0
- package/docs/inertia/middleware.md +81 -0
- package/docs/inertia/props.md +507 -0
- package/docs/inertia/references.md +144 -0
- package/docs/inertia/rendering.md +189 -0
- package/docs/inertia/ssr.md +102 -0
- package/docs/inspirations.md +257 -0
- package/docs/lifecycle.md +331 -0
- package/docs/lock.md +454 -0
- package/docs/logger.md +517 -0
- package/docs/media.md +582 -0
- package/docs/middleware.md +509 -0
- package/docs/migrations.md +529 -0
- package/docs/monitor.md +377 -0
- package/docs/notifications.md +848 -0
- package/docs/orm/casts.md +365 -0
- package/docs/orm/factories.md +231 -0
- package/docs/orm/index.md +663 -0
- package/docs/orm/lifecycle.md +421 -0
- package/docs/orm/queries.md +692 -0
- package/docs/orm/relationships.md +440 -0
- package/docs/orm/serialization.md +251 -0
- package/docs/package-development.md +536 -0
- package/docs/pagination.md +340 -0
- package/docs/password-reset.md +335 -0
- package/docs/providers.md +447 -0
- package/docs/query-builder.md +465 -0
- package/docs/queue.md +549 -0
- package/docs/rate-limiting.md +253 -0
- package/docs/responses.md +336 -0
- package/docs/roles-and-2fa.md +418 -0
- package/docs/routing.md +1008 -0
- package/docs/scaffolding.md +335 -0
- package/docs/scheduler.md +533 -0
- package/docs/seeding.md +229 -0
- package/docs/session.md +451 -0
- package/docs/social.md +524 -0
- package/docs/storage.md +622 -0
- package/docs/structure.md +230 -0
- package/docs/support-policy.md +114 -0
- package/docs/telemetry.md +505 -0
- package/docs/tenancy.md +608 -0
- package/docs/testing/browser.md +153 -0
- package/docs/testing/console.md +130 -0
- package/docs/testing/database.md +238 -0
- package/docs/testing/flow-browser.md +216 -0
- package/docs/testing/http.md +441 -0
- package/docs/testing/index.md +240 -0
- package/docs/testing/mocking.md +410 -0
- package/docs/upgrade.md +192 -0
- package/docs/validator.md +549 -0
- package/docs/view.md +453 -0
- package/package.json +60 -0
- package/src/bin/mcp.ts +73 -0
- package/src/config.ts +63 -0
- package/src/errors.ts +27 -0
- package/src/index.ts +56 -0
- package/src/install/ArchInstallCommand.ts +189 -0
- package/src/install/detect.ts +98 -0
- package/src/install/guidelines.ts +290 -0
- package/src/install/markers.ts +77 -0
- package/src/install/mcpConfig.ts +81 -0
- package/src/mcp/index.ts +27 -0
- package/src/mcp/jsonrpc.ts +133 -0
- package/src/mcp/server.ts +307 -0
- package/src/mcp/stdio.ts +111 -0
- package/src/mcp/types.ts +146 -0
- package/src/probe/ArchProbeCommand.ts +48 -0
- package/src/probe/sentinel.ts +13 -0
- package/src/probe/topics.ts +291 -0
- package/src/provider/ArchProvider.ts +101 -0
- package/src/tools/_probe.ts +164 -0
- package/src/tools/apiSurface.ts +241 -0
- package/src/tools/appInfo.ts +88 -0
- package/src/tools/baselines.ts +210 -0
- package/src/tools/context.ts +37 -0
- package/src/tools/doctor.ts +93 -0
- package/src/tools/index.ts +50 -0
- package/src/tools/logs.ts +265 -0
- package/src/tools/routes.ts +133 -0
- package/src/tools/schema.ts +119 -0
- package/src/tools/searchDocs.ts +345 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog — @zerotal/arch
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented here. The format is
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
**Maturity: beta.** The API is close to final and breaking changes are rare, called out
|
|
8
|
+
here with migration steps — but a minor release may still contain one.
|
|
9
|
+
|
|
10
|
+
## [1.7.0] — 2026-08-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **The agent surface.** An MCP server exposing what the framework already knows about an
|
|
15
|
+
app: `app_info`, `api_surface`, `search_docs`, `routes`, `schema`, `logs`, `last_error`,
|
|
16
|
+
`baselines` and `doctor`. Every tool is read-only and publishes an `outputSchema`.
|
|
17
|
+
- **`zt arch:install` / `zt arch:update`.** Writes `.mcp.json`, `AGENTS.md` and a
|
|
18
|
+
`CLAUDE.md` shim, detecting Cursor and VS Code configs alongside. Every generated region
|
|
19
|
+
is marker-fenced, so re-running preserves anything written around it. `--dry` shows what
|
|
20
|
+
would change.
|
|
21
|
+
- **`zt arch:probe <topic>`.** Prints one JSON report — `doctor`, `routes`, `schema` or
|
|
22
|
+
`app-info` — for the tools that need a booted app.
|
|
23
|
+
- **Dual-era MCP.** Serves the stateless `2026-07-28` revision, including the mandatory
|
|
24
|
+
`server/discover`, and the `initialize` handshake of `2025-11-25` and earlier. The era is
|
|
25
|
+
selected per request.
|
|
26
|
+
- **A vendored documentation corpus.** The framework's hand-written pages ship inside this
|
|
27
|
+
package, so `search_docs` is version-matched by construction — no embeddings, no hosted
|
|
28
|
+
API, and no way to answer from documentation for a version the app is not running.
|
|
29
|
+
- **A doctor check** reporting whether the MCP server is actually registered anywhere. A
|
|
30
|
+
project that installed the package and never ran `arch:install` has an agent surface
|
|
31
|
+
connected to nothing, which looks exactly like it working.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zerotal
|
|
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
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @zerotal/arch
|
|
2
|
+
|
|
3
|
+
**Maturity: beta.** The API is close to final and breaking changes are rare, called out
|
|
4
|
+
in release notes with migration steps — but a minor release may still contain one. See
|
|
5
|
+
the [support policy](https://zerotal.dev/docs/support-policy#maturity-levels).
|
|
6
|
+
|
|
7
|
+
The Zerotal agent surface: an MCP server that hands a coding agent the framework's
|
|
8
|
+
machine-readable truth about your app.
|
|
9
|
+
|
|
10
|
+
Not a documentation search over prose about an API — the API itself. Zerotal commits an
|
|
11
|
+
`api-surface.md` per package holding every export's exact TypeScript signature,
|
|
12
|
+
regenerated and diffed by CI on every change. `zt doctor` already returns structured
|
|
13
|
+
findings with a fix attached to each. The router knows its routes and the ORM knows its
|
|
14
|
+
columns. This package exposes all of it over the protocol agents speak.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bun add -d @zerotal/arch
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
// bootstrap/providers.ts
|
|
24
|
+
import { ArchProvider } from "@zerotal/arch";
|
|
25
|
+
|
|
26
|
+
export default [DatabaseProvider, ArchProvider];
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun zt arch:install # writes .mcp.json, AGENTS.md and a CLAUDE.md shim
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Re-running is safe: generated regions are fenced with markers and only those regions are
|
|
34
|
+
ever rewritten.
|
|
35
|
+
|
|
36
|
+
## Tools
|
|
37
|
+
|
|
38
|
+
| Tool | Answers |
|
|
39
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
40
|
+
| `app_info` | Bun version, boot mode, providers, and the version and maturity of every installed `@zerotal` package. |
|
|
41
|
+
| `api_surface` | Every export of a package with its full signature. |
|
|
42
|
+
| `search_docs` | The framework docs for the version installed here. |
|
|
43
|
+
| `routes` | The routes actually registered, with their names. |
|
|
44
|
+
| `schema` | Tables, columns, indexes — what the models declare. |
|
|
45
|
+
| `logs` / `last_error` | The app's own structured trail. |
|
|
46
|
+
| `baselines` | The quality ratchets and the commands that check them. |
|
|
47
|
+
| `doctor` | Every health check, with the fix beside each finding. |
|
|
48
|
+
|
|
49
|
+
All read-only. All publish an `outputSchema`.
|
|
50
|
+
|
|
51
|
+
## How it runs
|
|
52
|
+
|
|
53
|
+
The server is a bin that **never boots your application**. MCP's stdio transport forbids
|
|
54
|
+
writing anything to stdout that is not a protocol message, and a booted app prints. The
|
|
55
|
+
tools that need an app spawn one per call instead — which also means every answer
|
|
56
|
+
describes the code as it is now, not as it was when a long-lived server started.
|
|
57
|
+
|
|
58
|
+
It speaks both eras of MCP: the stateless `2026-07-28` revision, including the mandatory
|
|
59
|
+
`server/discover`, and the `initialize` handshake that shipping clients still open with.
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
<https://zerotal.dev/docs/arch>
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|
package/api-surface.md
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# @zerotal/arch — public API surface
|
|
2
|
+
|
|
3
|
+
<!-- AUTO-GENERATED by scripts/api-surface.ts. Do not edit by hand.
|
|
4
|
+
Run `bun run api:surface` to regenerate after an intentional API change. -->
|
|
5
|
+
|
|
6
|
+
## . `(./src/index.ts)`
|
|
7
|
+
|
|
8
|
+
class ArchError = {
|
|
9
|
+
new (message: string, code?: string, status?: number, context?: Record<string, unknown>): ArchError
|
|
10
|
+
readonly code: string
|
|
11
|
+
readonly context?: Record<string, unknown> | undefined
|
|
12
|
+
readonly status: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class ArchProvider = {
|
|
16
|
+
new (app: Application): ArchProvider
|
|
17
|
+
static dependsOn?: (new (app: Application) => ServiceProvider)[]
|
|
18
|
+
static environments: AppEnvironment[]
|
|
19
|
+
static priority?: number
|
|
20
|
+
static provides: readonly []
|
|
21
|
+
devProcesses: () => DevProcessDefinition[]
|
|
22
|
+
doctorChecks: () => DoctorCheck[]
|
|
23
|
+
onBooted: () => Promise<void>
|
|
24
|
+
onBooting: () => Promise<void>
|
|
25
|
+
onRegister: () => void
|
|
26
|
+
onRequestProcessed: (_ctx: HttpContext) => Promise<void>
|
|
27
|
+
onRequestReceived: (_ctx: HttpContext) => Promise<void>
|
|
28
|
+
onResponseSent: (_ctx: HttpContext) => Promise<void>
|
|
29
|
+
onStarted: () => Promise<void>
|
|
30
|
+
onStarting: () => Promise<void>
|
|
31
|
+
onStopped: () => Promise<void>
|
|
32
|
+
onStopping: () => Promise<void>
|
|
33
|
+
replContext: () => Record<string, unknown>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class NoProjectRootError = {
|
|
37
|
+
new (dir: string): NoProjectRootError
|
|
38
|
+
readonly code: string
|
|
39
|
+
readonly context?: Record<string, unknown> | undefined
|
|
40
|
+
readonly status: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const BLOCK_END = '<!-- zerotal:arch:end -->'
|
|
44
|
+
|
|
45
|
+
const BLOCK_START = '<!-- zerotal:arch:start -->'
|
|
46
|
+
|
|
47
|
+
const PROBE_TOPICS = readonly ['doctor', 'routes', 'schema', 'app-info']
|
|
48
|
+
|
|
49
|
+
const SERVER_ENTRY_PATH = 'node_modules/@zerotal/arch/src/bin/mcp.ts'
|
|
50
|
+
|
|
51
|
+
function agentsPreamble = () => string
|
|
52
|
+
|
|
53
|
+
function applyBlock = (existing: string | undefined, content: string, preamble?: string) => BlockOutcome
|
|
54
|
+
|
|
55
|
+
function applyMcpConfig = (existing: string | undefined, name: string, target: McpTarget) => ConfigOutcome
|
|
56
|
+
|
|
57
|
+
function ArchConfig = (options?: Partial<ArchConfigShape>) => ArchConfigShape
|
|
58
|
+
|
|
59
|
+
function archTools = (ctx: ToolContext) => ArchTool[]
|
|
60
|
+
|
|
61
|
+
function buildGuidelines = (options: GuidelineOptions) => string
|
|
62
|
+
|
|
63
|
+
function claudeShim = () => string
|
|
64
|
+
|
|
65
|
+
function detectAgents = (root: string) => Promise<Detected>
|
|
66
|
+
|
|
67
|
+
function fence = (content: string) => string
|
|
68
|
+
|
|
69
|
+
function findApp = (start: string) => Promise<{ root: string; entry: string;} | undefined>
|
|
70
|
+
|
|
71
|
+
function isProbeTopic = (value: string) => value is ProbeTopic
|
|
72
|
+
|
|
73
|
+
function probe = (topic: ProbeTopic, app: Application) => Promise<unknown>
|
|
74
|
+
|
|
75
|
+
function serverEntry = () => Record<string, unknown>
|
|
76
|
+
|
|
77
|
+
function spawnProbe = (options?: SpawnProbeOptions) => ProbeRunner
|
|
78
|
+
|
|
79
|
+
function vendoredDocsDir = () => string
|
|
80
|
+
|
|
81
|
+
interface AppInfo = {
|
|
82
|
+
appEnv: string
|
|
83
|
+
bun: string
|
|
84
|
+
environment: string
|
|
85
|
+
packages: InstalledPackage[]
|
|
86
|
+
providers: string[]
|
|
87
|
+
url?: string
|
|
88
|
+
webSocketPaths: string[]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface ArchConfigShape = {
|
|
92
|
+
agentsFile: boolean
|
|
93
|
+
claudeFile: boolean
|
|
94
|
+
mcpConfig: boolean
|
|
95
|
+
mcpConfigPath: string
|
|
96
|
+
serverName: string
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface Detected = {
|
|
100
|
+
agents: string[]
|
|
101
|
+
targets: McpTarget[]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface DoctorFinding = {
|
|
105
|
+
fix?: string
|
|
106
|
+
id: string
|
|
107
|
+
label: string
|
|
108
|
+
message: string
|
|
109
|
+
status: 'ok' | 'warn' | 'fail'
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface DoctorReport = {
|
|
113
|
+
counts: { ok: number; warn: number; fail: number; total: number;}
|
|
114
|
+
findings: DoctorFinding[]
|
|
115
|
+
healthy: boolean
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface GuidelineOptions = {
|
|
119
|
+
packages: string[]
|
|
120
|
+
serverName: string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface InstalledPackage = {
|
|
124
|
+
maturity?: string
|
|
125
|
+
name: string
|
|
126
|
+
version: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface McpTarget = {
|
|
130
|
+
client: string
|
|
131
|
+
key: 'mcpServers' | 'servers'
|
|
132
|
+
path: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface ProbeRunner = {
|
|
136
|
+
run: (topic: ProbeTopic, signal: AbortSignal) => Promise<ProbeResult>
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface RouteEntry = {
|
|
140
|
+
action: string
|
|
141
|
+
controller: string
|
|
142
|
+
domain?: string
|
|
143
|
+
method: string
|
|
144
|
+
middleware: string[]
|
|
145
|
+
name?: string
|
|
146
|
+
path: string
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface RouteReport = {
|
|
150
|
+
routes: RouteEntry[]
|
|
151
|
+
total: number
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface SchemaColumn = {
|
|
155
|
+
indexed: boolean
|
|
156
|
+
name: string
|
|
157
|
+
nullable: boolean
|
|
158
|
+
primary: boolean
|
|
159
|
+
type: string
|
|
160
|
+
unique: boolean
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface SchemaModel = {
|
|
164
|
+
columns: SchemaColumn[]
|
|
165
|
+
primaryKey: string
|
|
166
|
+
softDeletes: boolean
|
|
167
|
+
table: string
|
|
168
|
+
timestamps: boolean
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface SchemaReport = {
|
|
172
|
+
models: SchemaModel[]
|
|
173
|
+
note?: string
|
|
174
|
+
total: number
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface SpawnProbeOptions = {
|
|
178
|
+
cwd?: string
|
|
179
|
+
timeoutMs?: number
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface ToolContext = {
|
|
183
|
+
docsDir: string
|
|
184
|
+
probe: ProbeRunner
|
|
185
|
+
root: string
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type BlockOutcome = { status: 'created'; text: string;} | { status: 'updated'; text: string;} | { status: 'unchanged'; text: string;} | { status: 'conflict'; reason: string;}
|
|
189
|
+
|
|
190
|
+
type ConfigOutcome = { status: 'created' | 'updated' | 'unchanged'; text: string;} | { status: 'conflict'; reason: string;}
|
|
191
|
+
|
|
192
|
+
type ProbeResult = { ok: true; data: unknown;} | { ok: false; message: string;}
|
|
193
|
+
|
|
194
|
+
type ProbeTopic = 'doctor' | 'routes' | 'schema' | 'app-info'
|
|
195
|
+
|
|
196
|
+
## ./mcp `(./src/mcp/index.ts)`
|
|
197
|
+
|
|
198
|
+
class McpServer = {
|
|
199
|
+
new (options: McpServerOptions): McpServer
|
|
200
|
+
handle: (request: JsonRpcRequest) => Promise<JsonRpcResponse | undefined>
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const LEGACY_VERSIONS = readonly ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']
|
|
204
|
+
|
|
205
|
+
const Meta = { readonly PROTOCOL_VERSION: 'io.modelcontextprotocol/protocolVersion'; readonly CLIENT_INFO: 'io.modelcontextprotocol/clientInfo'; readonly CLIENT_CAPABILITIES: 'io.modelcontextprotocol/clientCapabilities'; readonly SERVER_INFO: 'io.modelcontextprotocol/serverInfo';}
|
|
206
|
+
|
|
207
|
+
const MODERN_VERSION = '2026-07-28'
|
|
208
|
+
|
|
209
|
+
const RpcError = { readonly PARSE: -32700; readonly INVALID_REQUEST: -32600; readonly METHOD_NOT_FOUND: -32601; readonly INVALID_PARAMS: -32602; readonly INTERNAL: -32603; readonly UNSUPPORTED_PROTOCOL_VERSION: -32022;}
|
|
210
|
+
|
|
211
|
+
const SUPPORTED_VERSIONS = readonly ['2026-07-28', '2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']
|
|
212
|
+
|
|
213
|
+
function decodeFrame = (line: string) => DecodedFrame | undefined
|
|
214
|
+
|
|
215
|
+
function encodeFrame = (message: JsonRpcResponse) => string
|
|
216
|
+
|
|
217
|
+
function failure = (id: JsonRpcId | null, code: number, message: string, data?: unknown) => JsonRpcFailure
|
|
218
|
+
|
|
219
|
+
function serveStdio = (options: StdioOptions) => Promise<void>
|
|
220
|
+
|
|
221
|
+
function success = (id: JsonRpcId, result: Record<string, unknown>) => JsonRpcResponse
|
|
222
|
+
|
|
223
|
+
interface ArchTool = {
|
|
224
|
+
description: string
|
|
225
|
+
inputSchema: JsonSchema
|
|
226
|
+
name: string
|
|
227
|
+
outputSchema: JsonSchema
|
|
228
|
+
run: (args: Record<string, unknown>, signal: AbortSignal) => Promise<ToolOutcome>
|
|
229
|
+
title: string
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface JsonRpcFailure = {
|
|
233
|
+
error: { code: number; message: string; data?: unknown;}
|
|
234
|
+
id: JsonRpcId | null
|
|
235
|
+
jsonrpc: '2.0'
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
interface JsonRpcRequest = {
|
|
239
|
+
id?: JsonRpcId
|
|
240
|
+
jsonrpc: '2.0'
|
|
241
|
+
method: string
|
|
242
|
+
params?: Record<string, unknown>
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface JsonRpcSuccess = {
|
|
246
|
+
id: JsonRpcId
|
|
247
|
+
jsonrpc: '2.0'
|
|
248
|
+
result: Record<string, unknown>
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface McpServerOptions = {
|
|
252
|
+
identity: ServerIdentity
|
|
253
|
+
tools: readonly ArchTool[]
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface ServerIdentity = {
|
|
257
|
+
name: string
|
|
258
|
+
title: string
|
|
259
|
+
version: string
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface StdioOptions = {
|
|
263
|
+
input?: ReadableStream<Uint8Array<ArrayBufferLike>>
|
|
264
|
+
log?: (message: string) => void
|
|
265
|
+
server: McpServer
|
|
266
|
+
write?: (frame: string) => void
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
interface ToolOutcome = {
|
|
270
|
+
data?: unknown
|
|
271
|
+
failed?: boolean
|
|
272
|
+
text: string
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
type DecodedFrame = { ok: true; request: JsonRpcRequest;} | { ok: false; failure: JsonRpcFailure;}
|
|
276
|
+
|
|
277
|
+
type Era = 'modern' | 'legacy'
|
|
278
|
+
|
|
279
|
+
type JsonRpcId = string | number
|
|
280
|
+
|
|
281
|
+
type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure
|
|
282
|
+
|
|
283
|
+
type JsonSchema = { [x: string]: unknown;}
|