hmcp-gateway 0.0.2 → 0.2.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 +135 -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 +355 -0
- package/dist/adopt-cli.js +1885 -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 +501 -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 +656 -0
- package/dist/client-allow.d.ts +42 -0
- package/dist/client-allow.js +95 -0
- package/dist/client-config.d.ts +263 -0
- package/dist/client-config.js +995 -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 +51 -0
- package/dist/connect-client.js +299 -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/desktop-extensions.d.ts +53 -0
- package/dist/desktop-extensions.js +126 -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 +766 -0
- package/dist/gateway.js +2122 -0
- package/dist/github-doors.d.ts +162 -0
- package/dist/github-doors.js +780 -0
- package/dist/guard-install.d.ts +109 -0
- package/dist/guard-install.js +396 -0
- package/dist/guard.d.ts +265 -0
- package/dist/guard.js +975 -0
- package/dist/import-client.d.ts +184 -0
- package/dist/import-client.js +578 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +31 -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/toml-edit.d.ts +43 -0
- package/dist/toml-edit.js +363 -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 +51 -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,162 @@
|
|
|
1
|
+
import { type ClaudeServer } from "./client-config.js";
|
|
2
|
+
import type { Upstream } from "./config.js";
|
|
3
|
+
/**
|
|
4
|
+
* The other ways an AI app on this computer can change GitHub without going
|
|
5
|
+
* through hmcp -- the "doors" around the toolbox.
|
|
6
|
+
*
|
|
7
|
+
* hmcp can hold a GitHub change for a person only if the change goes through
|
|
8
|
+
* it. Claude Code also has a terminal, and in that terminal `gh` and
|
|
9
|
+
* `git push` reach GitHub with whatever sign-in this computer already has.
|
|
10
|
+
* So a toolbox that asks before every change is only a safety layer if those
|
|
11
|
+
* other ways are shut, and this module is how the console finds out which
|
|
12
|
+
* ones are open.
|
|
13
|
+
*
|
|
14
|
+
* Two rules run through all of it. Detection only ever reads, and reports
|
|
15
|
+
* names and yes/no answers: never a token, a password line, a URL or a
|
|
16
|
+
* command line, because the answer travels to a browser. And a door that
|
|
17
|
+
* cannot be checked from here says so ("unknown") rather than being reported
|
|
18
|
+
* shut: Claude's own GitHub connection lives on Anthropic's servers, and a
|
|
19
|
+
* password kept in the system keychain can only be read by asking the person.
|
|
20
|
+
*
|
|
21
|
+
* The one door this can close is Claude Code's, because Claude Code enforces
|
|
22
|
+
* its own `permissions.deny` rules. Closing it adds exactly three rules, keeps
|
|
23
|
+
* a record of which of them it added, and undo removes only those.
|
|
24
|
+
*/
|
|
25
|
+
export type GithubDoorId = "claude-code-terminal" | "gh-login" | "git-credentials" | "env-token" | "other-servers" | "github-app-access" | "claude-connector";
|
|
26
|
+
/** The doors only a person, signed in, can close: hmcp can only open the page and remember their answer. */
|
|
27
|
+
export declare const MANUAL_GITHUB_DOORS: readonly ["github-app-access", "claude-connector"];
|
|
28
|
+
export type ManualGithubDoorId = (typeof MANUAL_GITHUB_DOORS)[number];
|
|
29
|
+
/** Why those two can't be closed from here, in one line. */
|
|
30
|
+
export declare const MANUAL_DOOR_WHY = "GitHub and Anthropic only let you, signed in, remove an app's access \u2014 no program can do it for you, which is what keeps malware from doing it.";
|
|
31
|
+
/** A page to open, and the button to press once it is open. */
|
|
32
|
+
export interface GithubDoorLink {
|
|
33
|
+
readonly label: string;
|
|
34
|
+
readonly url: string;
|
|
35
|
+
readonly press: string;
|
|
36
|
+
}
|
|
37
|
+
export interface GithubDoor {
|
|
38
|
+
readonly id: GithubDoorId;
|
|
39
|
+
readonly label: string;
|
|
40
|
+
/**
|
|
41
|
+
* "unknown": it can't be checked from this computer, which is not the same
|
|
42
|
+
* as shut. "harder": Claude Code's block is in place, which makes a way
|
|
43
|
+
* around hmcp much harder but is never a guarantee, so never "closed".
|
|
44
|
+
*/
|
|
45
|
+
readonly state: "open" | "closed" | "harder" | "unknown";
|
|
46
|
+
/** What was found, in plain words. Names and places only, never a value. */
|
|
47
|
+
readonly detail: string;
|
|
48
|
+
/** What to do about it, as steps. Empty when there is nothing to do. */
|
|
49
|
+
readonly fix: readonly string[];
|
|
50
|
+
/** Claude Code's door only: which settings hold rules hmcp added, so can be undone. */
|
|
51
|
+
readonly undoable?: readonly ClaudeCodeScope[];
|
|
52
|
+
/** A door only a person can close: the pages to open, and why it can't be done for them. */
|
|
53
|
+
readonly links?: readonly GithubDoorLink[];
|
|
54
|
+
readonly why?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The person said they closed it. "closed" then means "you confirmed", not
|
|
57
|
+
* "checked": nothing on this computer can see the other side.
|
|
58
|
+
*/
|
|
59
|
+
readonly confirmed?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Where the block goes: every project, or only the one the console is looking at. */
|
|
62
|
+
export type ClaudeCodeScope = "user" | "project";
|
|
63
|
+
/**
|
|
64
|
+
* The rules. `gh` and `git push` are the two commands that change GitHub with
|
|
65
|
+
* this computer's own sign-in; the WebFetch rule stops Claude Code's own web
|
|
66
|
+
* tool calling GitHub's API. Claude Code checks deny rules before it runs
|
|
67
|
+
* anything, and a deny wins over an allow in any settings file.
|
|
68
|
+
*/
|
|
69
|
+
export declare const CLAUDE_CODE_GITHUB_RULES: readonly ["Bash(gh:*)", "Bash(git push:*)", "WebFetch(domain:api.github.com)"];
|
|
70
|
+
/**
|
|
71
|
+
* git's settings outside the home folder. Apple's git turns the macOS
|
|
72
|
+
* keychain on in its own file, so a Mac with nothing in `~/.gitconfig` can
|
|
73
|
+
* still have GitHub's password saved; Git for Windows does the same with Git
|
|
74
|
+
* Credential Manager. Read only, and only to see which password helper is
|
|
75
|
+
* named.
|
|
76
|
+
*/
|
|
77
|
+
export declare function defaultSystemGitConfigs(env: Readonly<Record<string, string | undefined>>, platform: string): string[];
|
|
78
|
+
/** One server an AI app runs itself, outside the toolbox. */
|
|
79
|
+
export interface AppServer {
|
|
80
|
+
/** The app, e.g. "Cursor (all projects)". */
|
|
81
|
+
readonly client: string;
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly server: ClaudeServer;
|
|
84
|
+
}
|
|
85
|
+
export interface GithubDoorOptions {
|
|
86
|
+
readonly home: string;
|
|
87
|
+
/** The project folder, for Claude Code's project settings and the apps' project files. */
|
|
88
|
+
readonly cwd: string;
|
|
89
|
+
/** The console's environment. Only the names of the key variables are ever looked at. */
|
|
90
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
91
|
+
readonly platform?: string;
|
|
92
|
+
/** Overridable so a test never reads this computer's own git settings. */
|
|
93
|
+
readonly systemGitConfigs?: readonly string[];
|
|
94
|
+
/** A small text file's contents, or undefined when it isn't there. Overridable for tests. */
|
|
95
|
+
readonly readFile?: (path: string) => string | undefined;
|
|
96
|
+
/** The servers each app runs itself. Defaults to reading the apps' own settings files. */
|
|
97
|
+
readonly listAppServers?: () => {
|
|
98
|
+
servers: AppServer[];
|
|
99
|
+
unreadable: string[];
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Claude Code's settings file for a scope. A project gets its local file, which Claude Code keeps out of git. */
|
|
103
|
+
export declare function claudeCodeSettingsPath(scope: ClaudeCodeScope, options: {
|
|
104
|
+
home: string;
|
|
105
|
+
cwd: string;
|
|
106
|
+
}): string;
|
|
107
|
+
export declare function githubDoors(options: GithubDoorOptions): GithubDoor[];
|
|
108
|
+
export declare function claudeCodeGithubUndoPath(home: string): string;
|
|
109
|
+
export interface ClaudeCodeGithubOptions {
|
|
110
|
+
readonly settingsPath: string;
|
|
111
|
+
/** Where the undo record is kept (`<home>/.hmcp`). */
|
|
112
|
+
readonly home: string;
|
|
113
|
+
/** Whether file names ignore case here (macOS, Windows), for the undo record's key. */
|
|
114
|
+
readonly platform?: string;
|
|
115
|
+
}
|
|
116
|
+
/** Adds whichever of the three rules are missing. `added` is empty, and nothing written, when all were there. */
|
|
117
|
+
export declare function closeClaudeCodeGithub(options: ClaudeCodeGithubOptions): {
|
|
118
|
+
settingsPath: string;
|
|
119
|
+
added: string[];
|
|
120
|
+
};
|
|
121
|
+
/** Removes only the rules hmcp added to this file. `removed` is empty when it added none. */
|
|
122
|
+
export declare function reopenClaudeCodeGithub(options: ClaudeCodeGithubOptions): {
|
|
123
|
+
settingsPath: string;
|
|
124
|
+
removed: string[];
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Whether a project's `.claude/settings.local.json` is kept out of git, read
|
|
128
|
+
* from its `.gitignore` files only (never edited). Null when the folder isn't
|
|
129
|
+
* a git repository. A rule given in a global ignore file isn't seen, so
|
|
130
|
+
* `false` means "not that we can see".
|
|
131
|
+
*/
|
|
132
|
+
export declare function projectSettingsIgnored(projectDir: string): boolean | null;
|
|
133
|
+
export declare function githubDoorConfirmationsPath(home: string): string;
|
|
134
|
+
export declare function readGithubDoorConfirmations(home: string): Set<ManualGithubDoorId>;
|
|
135
|
+
export declare function isManualGithubDoor(id: string): id is ManualGithubDoorId;
|
|
136
|
+
export declare function confirmGithubDoor(options: {
|
|
137
|
+
home: string;
|
|
138
|
+
door: string;
|
|
139
|
+
done: boolean;
|
|
140
|
+
}): Set<ManualGithubDoorId>;
|
|
141
|
+
/** Whether a toolbox's server is GitHub's: by its name, address or what it runs. */
|
|
142
|
+
export declare function isGithubUpstream(upstream: Upstream): boolean;
|
|
143
|
+
/** GitHub's hosted server: the address that can make changes, and the one that can only look. */
|
|
144
|
+
export declare const GITHUB_HOSTED_URL = "https://api.githubcopilot.com/mcp/";
|
|
145
|
+
export declare const GITHUB_HOSTED_READONLY_URL = "https://api.githubcopilot.com/mcp/readonly";
|
|
146
|
+
/**
|
|
147
|
+
* Which of GitHub's two hosted addresses this is, or null for any other
|
|
148
|
+
* address. Only these two are switched by the console: any other address is
|
|
149
|
+
* the person's own, and changing it would be a guess.
|
|
150
|
+
*/
|
|
151
|
+
export declare function githubHostedAccess(upstream: Upstream): "readonly" | "changes" | null;
|
|
152
|
+
/**
|
|
153
|
+
* GitHub's hosted server also goes read-only when asked with the
|
|
154
|
+
* `X-MCP-Readonly` header, whatever the address. A key kept as a locked-key
|
|
155
|
+
* reference isn't read: only a written value counts.
|
|
156
|
+
*/
|
|
157
|
+
export declare function githubReadonlyHeader(upstream: Upstream): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The GitHub pack's tools that change something, by their own names: what
|
|
160
|
+
* the self-check looks for once changes are switched on.
|
|
161
|
+
*/
|
|
162
|
+
export declare function githubChangeTools(): string[];
|