hmcp-gateway 0.0.2 → 0.1.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/LICENSE +77 -0
- package/README.md +41 -9
- package/bin/hmcp-gateway.js +20 -0
- package/catalog/atlassian.yaml +41 -0
- package/catalog/brave-search.yaml +57 -0
- package/catalog/context7.yaml +42 -0
- package/catalog/fetch.yaml +37 -0
- package/catalog/figma.yaml +48 -0
- package/catalog/filesystem.yaml +48 -0
- package/catalog/git.yaml +48 -0
- package/catalog/github.yaml +103 -0
- package/catalog/huggingface.yaml +59 -0
- package/catalog/linear.yaml +47 -0
- package/catalog/memory.yaml +47 -0
- package/catalog/notion.yaml +41 -0
- package/catalog/playwright.yaml +38 -0
- package/catalog/postgres.yaml +66 -0
- package/catalog/sentry.yaml +39 -0
- package/catalog/sequential-thinking.yaml +29 -0
- package/catalog/stripe.yaml +41 -0
- package/catalog/supabase.yaml +45 -0
- package/catalog/time.yaml +49 -0
- package/dist/adopt-cli.d.ts +351 -0
- package/dist/adopt-cli.js +1857 -0
- package/dist/adopt-emit.d.ts +64 -0
- package/dist/adopt-emit.js +248 -0
- package/dist/adopt-plan.d.ts +108 -0
- package/dist/adopt-plan.js +386 -0
- package/dist/catalog.d.ts +140 -0
- package/dist/catalog.js +250 -0
- package/dist/classify.d.ts +23 -0
- package/dist/classify.js +47 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +535 -0
- package/dist/client-allow.d.ts +42 -0
- package/dist/client-allow.js +95 -0
- package/dist/client-config.d.ts +200 -0
- package/dist/client-config.js +784 -0
- package/dist/config-source.d.ts +106 -0
- package/dist/config-source.js +156 -0
- package/dist/config.d.ts +159 -0
- package/dist/config.js +330 -0
- package/dist/connect-client.d.ts +49 -0
- package/dist/connect-client.js +249 -0
- package/dist/contracts.d.ts +251 -0
- package/dist/contracts.js +9 -0
- package/dist/credential.d.ts +63 -0
- package/dist/credential.js +136 -0
- package/dist/draft.d.ts +71 -0
- package/dist/draft.js +596 -0
- package/dist/exposure-cli.d.ts +28 -0
- package/dist/exposure-cli.js +119 -0
- package/dist/gateway.d.ts +756 -0
- package/dist/gateway.js +2106 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/notify.d.ts +44 -0
- package/dist/notify.js +93 -0
- package/dist/oauth.d.ts +139 -0
- package/dist/oauth.js +641 -0
- package/dist/observe.d.ts +10 -0
- package/dist/observe.js +26 -0
- package/dist/open.d.ts +24 -0
- package/dist/open.js +31 -0
- package/dist/packs.d.ts +119 -0
- package/dist/packs.js +131 -0
- package/dist/pin-cli.d.ts +28 -0
- package/dist/pin-cli.js +103 -0
- package/dist/probe-upstream.d.ts +31 -0
- package/dist/probe-upstream.js +377 -0
- package/dist/registry-map.d.ts +39 -0
- package/dist/registry-map.js +390 -0
- package/dist/rule-cli.d.ts +51 -0
- package/dist/rule-cli.js +412 -0
- package/dist/serve-http.d.ts +67 -0
- package/dist/serve-http.js +478 -0
- package/dist/snippet.d.ts +20 -0
- package/dist/snippet.js +826 -0
- package/dist/status-cli.d.ts +61 -0
- package/dist/status-cli.js +195 -0
- package/dist/suggest-cli.d.ts +43 -0
- package/dist/suggest-cli.js +279 -0
- package/dist/toolname.d.ts +47 -0
- package/dist/toolname.js +149 -0
- package/dist/upstream-errors.d.ts +54 -0
- package/dist/upstream-errors.js +330 -0
- package/dist/upstream.d.ts +128 -0
- package/dist/upstream.js +413 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +11 -0
- package/package.json +50 -6
- package/packs/brave-search.yaml +20 -0
- package/packs/context7.yaml +13 -0
- package/packs/fetch.yaml +14 -0
- package/packs/filesystem.yaml +79 -0
- package/packs/git.yaml +29 -0
- package/packs/github.yaml +47 -0
- package/packs/huggingface.yaml +16 -0
- package/packs/memory.yaml +23 -0
- package/packs/playwright.yaml +41 -0
- package/packs/sequential-thinking.yaml +13 -0
- package/packs/time.yaml +14 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Claude Code's own MCP server configuration: finding it, reading it, and
|
|
4
|
+
* putting it back.
|
|
5
|
+
*
|
|
6
|
+
* This is the one file in the gateway that touches a config another program
|
|
7
|
+
* owns, and that ownership drives two departures from how every other schema
|
|
8
|
+
* here is written.
|
|
9
|
+
*
|
|
10
|
+
* The schemas are loose rather than `.strict()`. The gateway's own config is
|
|
11
|
+
* strict because the gateway defines it, and an unknown key there is a typo
|
|
12
|
+
* worth refusing. This format belongs to Claude Code, which adds fields
|
|
13
|
+
* between releases; a strict parse would make `adopt` refuse a config that is
|
|
14
|
+
* perfectly good and merely newer than this build.
|
|
15
|
+
*
|
|
16
|
+
* And entries are validated one at a time rather than as a whole file, so a
|
|
17
|
+
* single malformed entry costs itself and not every sibling. That is the same
|
|
18
|
+
* reasoning as `dropUnknownKinds` in core's registry: a config shared between
|
|
19
|
+
* versions must not let one bad row hide the rest.
|
|
20
|
+
*/
|
|
21
|
+
/** A server Claude Code starts as a child process. */
|
|
22
|
+
export declare const ClaudeStdioServerSchema: z.ZodObject<{
|
|
23
|
+
type: z.ZodOptional<z.ZodLiteral<"stdio">>;
|
|
24
|
+
command: z.ZodString;
|
|
25
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
26
|
+
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
27
|
+
}, z.core.$loose>;
|
|
28
|
+
/** A server Claude Code reaches over the network. */
|
|
29
|
+
export declare const ClaudeRemoteServerSchema: z.ZodObject<{
|
|
30
|
+
type: z.ZodEnum<{
|
|
31
|
+
http: "http";
|
|
32
|
+
sse: "sse";
|
|
33
|
+
}>;
|
|
34
|
+
url: z.ZodString;
|
|
35
|
+
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
36
|
+
}, z.core.$loose>;
|
|
37
|
+
export type ClaudeStdioServer = z.infer<typeof ClaudeStdioServerSchema>;
|
|
38
|
+
export type ClaudeRemoteServer = z.infer<typeof ClaudeRemoteServerSchema>;
|
|
39
|
+
export type ClaudeServer = ClaudeStdioServer | ClaudeRemoteServer;
|
|
40
|
+
export declare function isRemote(server: ClaudeServer): server is ClaudeRemoteServer;
|
|
41
|
+
export declare class ClientConfigError extends Error {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Where one scope's servers live.
|
|
45
|
+
*
|
|
46
|
+
* The first three are Claude Code's. The rest are other clients, each with
|
|
47
|
+
* its own file in its own place -- and, for VS Code, its own spelling of the
|
|
48
|
+
* same object. They are scopes rather than a separate concept because
|
|
49
|
+
* everything this command does to one of them is identical: read the servers,
|
|
50
|
+
* write a gateway entry in their place, and be able to put them back.
|
|
51
|
+
*/
|
|
52
|
+
export type Scope = "project" | "local" | "user" | "claude-desktop" | "cursor-project" | "cursor-user" | "vscode-project" | "vscode-user" | "windsurf";
|
|
53
|
+
export interface ScopeTarget {
|
|
54
|
+
readonly scope: Scope;
|
|
55
|
+
/** The JSON file holding them. */
|
|
56
|
+
readonly path: string;
|
|
57
|
+
/** Where inside that file, for an error message a human can act on. */
|
|
58
|
+
readonly where: string;
|
|
59
|
+
/**
|
|
60
|
+
* The top-level key the servers sit under. VS Code says `servers`;
|
|
61
|
+
* everything else says `mcpServers`, and writing the wrong one would add a
|
|
62
|
+
* key the client never reads while its own servers went on running
|
|
63
|
+
* unwrapped.
|
|
64
|
+
*/
|
|
65
|
+
readonly key: string;
|
|
66
|
+
/** Which program owns this file, for anything shown to a person. */
|
|
67
|
+
readonly client: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ScopeOptions {
|
|
70
|
+
readonly cwd?: string;
|
|
71
|
+
readonly home?: string;
|
|
72
|
+
/** Overridable so the per-platform paths can be tested on one machine. */
|
|
73
|
+
readonly platform?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The three places Claude Code keeps MCP servers, in the order it resolves
|
|
77
|
+
* them.
|
|
78
|
+
*
|
|
79
|
+
* `local` is per-project state inside the user-wide file, which is why its
|
|
80
|
+
* entry is keyed by an absolute project path rather than living next to the
|
|
81
|
+
* project.
|
|
82
|
+
*/
|
|
83
|
+
export declare function scopeTargets(options?: ScopeOptions): ScopeTarget[];
|
|
84
|
+
export interface ClientConfigFile {
|
|
85
|
+
readonly target: ScopeTarget;
|
|
86
|
+
/** The file's bytes as read, so a backup and an undo can be exact. Null when there is no file. */
|
|
87
|
+
readonly text: string | null;
|
|
88
|
+
/** The file had comments or trailing commas (VS Code allows both), so it is rewritten with care. */
|
|
89
|
+
readonly jsonc: boolean;
|
|
90
|
+
/** The whole file, so everything this command does not own survives a write. */
|
|
91
|
+
readonly raw: Record<string, unknown>;
|
|
92
|
+
/** The `mcpServers` object for this scope, values still unvalidated. */
|
|
93
|
+
readonly servers: Record<string, unknown>;
|
|
94
|
+
readonly exists: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Reads one scope.
|
|
98
|
+
*
|
|
99
|
+
* A missing file is an empty scope rather than an error, matching
|
|
100
|
+
* `readRegistry`: not having adopted anything yet is a state, not a fault.
|
|
101
|
+
*/
|
|
102
|
+
export declare function readClientConfig(scope: Scope, options?: ScopeOptions): ClientConfigFile;
|
|
103
|
+
/**
|
|
104
|
+
* JSON with comments, as VS Code reads its `mcp.json`: `//` and block
|
|
105
|
+
* comments and trailing commas removed, everything inside strings left alone.
|
|
106
|
+
* Every removed character becomes a space (newlines kept), so positions and
|
|
107
|
+
* line numbers in an error still point at the person's own file.
|
|
108
|
+
*/
|
|
109
|
+
export declare function stripJsonc(text: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Whether the file reads the same as `value`: same keys and values, whatever
|
|
112
|
+
* the spacing. Used to decide that an undo may put the original bytes back.
|
|
113
|
+
*/
|
|
114
|
+
export declare function sameJson(a: unknown, b: unknown): boolean;
|
|
115
|
+
export interface ParsedServers {
|
|
116
|
+
readonly servers: ReadonlyMap<string, ClaudeServer>;
|
|
117
|
+
/** Entries that did not validate, each with the reason, never silently dropped. */
|
|
118
|
+
readonly malformed: readonly {
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly message: string;
|
|
121
|
+
}[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Validates each entry on its own.
|
|
125
|
+
*
|
|
126
|
+
* An entry carrying `type: "http"` or `"sse"` is held to the remote shape
|
|
127
|
+
* rather than being offered to both: a remote entry missing its `url` should
|
|
128
|
+
* report that, not the stdio schema's complaint about a missing `command`.
|
|
129
|
+
*/
|
|
130
|
+
export declare function parseServers(raw: Record<string, unknown>): ParsedServers;
|
|
131
|
+
/**
|
|
132
|
+
* Which scope `adopt` should act on when nobody said.
|
|
133
|
+
*
|
|
134
|
+
* More than one populated scope refuses rather than merging. Which project
|
|
135
|
+
* sees which server is a semantic Claude Code owns, and collapsing three
|
|
136
|
+
* scopes into one gateway would change it -- a user-scope server would start
|
|
137
|
+
* being visible only in the project that happened to run `adopt`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function resolveScope(explicit: Scope | undefined, options?: ScopeOptions): ScopeTarget;
|
|
140
|
+
/**
|
|
141
|
+
* Writes `servers` back into the scope, leaving the rest of the file alone.
|
|
142
|
+
*
|
|
143
|
+
* The file keeps its own indent and its trailing newline (or lack of one).
|
|
144
|
+
* A file with comments (VS Code's JSONC) has only the server list's value
|
|
145
|
+
* replaced in its text, so every comment outside that list survives.
|
|
146
|
+
*/
|
|
147
|
+
export declare function writeClientConfig(file: ClientConfigFile, servers: Record<string, unknown>): void;
|
|
148
|
+
export interface RestoreResult {
|
|
149
|
+
/** "bytes": the original file came back exactly; "removed": the file did not exist before and is gone again. */
|
|
150
|
+
readonly how: "bytes" | "removed" | "rewritten";
|
|
151
|
+
/** A copy of the old file still on disk, which holds its old values. Null when none is left. */
|
|
152
|
+
readonly backupLeft: string | null;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Undo's write: puts `servers` back, and when that leaves the file exactly as
|
|
156
|
+
* it was before (same keys and values), writes the original bytes from the
|
|
157
|
+
* whole-file copy and removes the copy, so a file under version control shows
|
|
158
|
+
* no diff. A file that did not exist before and is now an empty skeleton is
|
|
159
|
+
* removed. Anything else -- the person changed the file since -- is written
|
|
160
|
+
* with the file's own indent, and the copy stays.
|
|
161
|
+
*/
|
|
162
|
+
export declare function restoreClientConfig(file: ClientConfigFile, servers: Record<string, unknown>): RestoreResult;
|
|
163
|
+
/** After undo: the project's backups folder goes once nothing but its own `.gitignore` is left in it. */
|
|
164
|
+
export declare function tidyProjectBackups(target: ScopeTarget): void;
|
|
165
|
+
/** A verbatim copy of the file before adoption touched it. One made by an earlier build, beside the file, is still used. */
|
|
166
|
+
export declare function wholeFileBackupPath(target: ScopeTarget): string;
|
|
167
|
+
/**
|
|
168
|
+
* The structured record `--revert` reads. Claude Code's file sits in the home
|
|
169
|
+
* folder itself, and its record went beside it, loose in the home folder
|
|
170
|
+
* (UT5); it is kept under that folder's `.hmcp` now. A project's record goes
|
|
171
|
+
* under the project's `.hmcp/backups` (UT5 round 3). A record left by an
|
|
172
|
+
* earlier build where it used to go is still read and removed.
|
|
173
|
+
*/
|
|
174
|
+
export declare function backupPath(target: ScopeTarget): string;
|
|
175
|
+
/** Where this target's record is now, if it has one. */
|
|
176
|
+
export declare function existingBackupPath(target: ScopeTarget): string | undefined;
|
|
177
|
+
export declare const AdoptBackupSchema: z.ZodObject<{
|
|
178
|
+
version: z.ZodLiteral<1>;
|
|
179
|
+
created_at: z.ZodString;
|
|
180
|
+
scope: z.ZodString;
|
|
181
|
+
config_path: z.ZodString;
|
|
182
|
+
gateway_entry_name: z.ZodString;
|
|
183
|
+
replaced: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
184
|
+
generated: z.ZodArray<z.ZodString>;
|
|
185
|
+
registry_id: z.ZodOptional<z.ZodString>;
|
|
186
|
+
client_allow: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
path: z.ZodString;
|
|
188
|
+
rule: z.ZodString;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
export type AdoptBackup = z.infer<typeof AdoptBackupSchema>;
|
|
192
|
+
export declare function readBackup(target: ScopeTarget): AdoptBackup | undefined;
|
|
193
|
+
export declare function writeBackup(target: ScopeTarget, backup: AdoptBackup): void;
|
|
194
|
+
/**
|
|
195
|
+
* Copies the file byte for byte, for the human who would rather just move it
|
|
196
|
+
* back, and for undo to put back exactly. A second connection to the same
|
|
197
|
+
* file (its adoption record is already there) keeps the first copy: that one
|
|
198
|
+
* is the file as it was before any of this.
|
|
199
|
+
*/
|
|
200
|
+
export declare function writeWholeFileBackup(file: ClientConfigFile): void;
|