@bridge-ds/mcp 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -7,28 +7,31 @@ propose token changes as reviewable branches and pull requests. It never writes
7
7
  Free and open source (MIT). Local, no backend, no account: it reads files on your disk, or a GitHub repo
8
8
  with your own token.
9
9
 
10
- > On npm: `npx -y @bridge-ds/mcp` runs it, nothing to build. The local path form (`node packages/mcp/dist/index.js`)
11
- > is for working on the server itself.
12
-
13
10
  ## Run it
14
11
 
12
+ From npm, nothing to build:
13
+
15
14
  ```sh
16
- npm run mcp:build # builds packages/mcp and packages/cli
17
- node packages/mcp/dist/index.js --root . # local repo (default: current directory)
18
- node packages/mcp/dist/index.js --repo owner/name # GitHub repo, read-only
19
- GITHUB_TOKEN=... node packages/mcp/dist/index.js --repo owner/name # GitHub repo, can open PRs
15
+ npx -y @bridge-ds/mcp --repo owner/name # GitHub repo, read-only
16
+ GITHUB_TOKEN=... npx -y @bridge-ds/mcp --repo owner/name # GitHub repo, can open PRs
17
+ npx -y @bridge-ds/mcp --root . # local folder (default: current directory)
18
+ npx -y @bridge-ds/mcp --help
20
19
  ```
21
20
 
22
21
  Connect it to Claude Code:
23
22
 
24
23
  ```sh
25
- claude mcp add bridge -- npx -y @bridge-ds/mcp --root /abs/path/to/your-ds
26
- # or a GitHub repo (pull requests need a token):
24
+ claude mcp add bridge -s user -- npx -y @bridge-ds/mcp --repo owner/name
25
+ # so Claude can open pull requests (a fine-grained token limited to that repo):
27
26
  claude mcp add bridge -s user -e GITHUB_TOKEN=your-github-token -- npx -y @bridge-ds/mcp --repo owner/name
27
+ # or a local checkout:
28
+ claude mcp add bridge -- npx -y @bridge-ds/mcp --root /abs/path/to/your-ds
28
29
  ```
29
30
 
30
- Or commit a project `.mcp.json` (this repo has one), or run `bridge init`. Claude Desktop, other clients
31
- and the full guide: [docs/AI.md](../../docs/AI.md).
31
+ Or commit a project `.mcp.json`. Claude Desktop, other clients and the full guide: [docs/AI.md](../../docs/AI.md).
32
+
33
+ Working on the server itself: `npm run mcp:build` in a clone of this repo builds it to
34
+ `packages/mcp/dist/index.js`, which this repo's own `.mcp.json` runs.
32
35
 
33
36
  ## Modes
34
37
 
@@ -1039,6 +1039,25 @@ var GitHubClient = class _GitHubClient {
1039
1039
  throw new GitHubError(422, `GitHub refused to mark #${n} ready for review${detail ? `: ${detail}` : "."} Use "Ready for review" on GitHub instead.`, detail);
1040
1040
  }
1041
1041
  }
1042
+ /**
1043
+ * Turns an open pull request back into a draft: the GraphQL mutation convertPullRequestToDraft (REST cannot set
1044
+ * `draft` either), same token. No-op when it is already a draft.
1045
+ */
1046
+ async convertToDraft(n) {
1047
+ this.assertToken("Turning a pull request back into a draft");
1048
+ const pr = await this.request("GET", `${this.repoPath}/pulls/${n}`);
1049
+ if (pr.draft === true) return;
1050
+ if (pr.state && pr.state !== "open") throw new GitHubError(422, `Pull request #${n} is ${pr.state}: only an open one can go back to draft.`);
1051
+ if (!pr.node_id) throw new GitHubError(422, `Pull request #${n} has no node id: convert it to draft on GitHub.`);
1052
+ const r = await this.request("POST", "/graphql", {
1053
+ query: "mutation($id: ID!) { convertPullRequestToDraft(input: { pullRequestId: $id }) { pullRequest { number isDraft } } }",
1054
+ variables: { id: pr.node_id }
1055
+ });
1056
+ if (r?.errors?.length) {
1057
+ const detail = r.errors.map((e) => e.message).filter(Boolean).join(" ");
1058
+ throw new GitHubError(422, `GitHub refused to turn #${n} back into a draft${detail ? `: ${detail}` : "."} Use "Convert to draft" on GitHub instead.`, detail);
1059
+ }
1060
+ }
1042
1061
  async createPullRequest(input) {
1043
1062
  this.assertWritableBranch(input.head, input.base);
1044
1063
  const r = await this.request(
@@ -3000,7 +3019,7 @@ function explorationPrBody(e, ctx) {
3000
3019
  `- **Promote:** in Bridge Studio (Changes, Explorations, Promote to review) or \`bridge explore promote ${slug2}\`. Bridge marks the pull request ready for review, removes the \`${EXPLORATION_LABEL}\` label and the exploration note, and adds the tier labels. Then it goes through the usual review.`,
3001
3020
  "- **Close:** close this pull request. The branch stays for reference; the preview prerelease is removed.",
3002
3021
  "",
3003
- `<!-- ${MARK} ${JSON.stringify({ name: e.name.trim(), purpose: e.purpose.trim(), slug: slug2, ...e.useCase ? { useCase: e.useCase } : {}, ...experimental.length ? { experimental } : {}, ...e.author ? { author: e.author } : {}, ...e.startedAt ? { startedAt: e.startedAt } : {} }).replace(/-->/g, "--\\u003e")} -->`
3022
+ `<!-- ${MARK} ${JSON.stringify({ name: e.name.trim(), purpose: e.purpose.trim(), slug: slug2, ...e.useCase ? { useCase: e.useCase } : {}, ...experimental.length ? { experimental } : {}, ...e.author ? { author: e.author } : {}, ...e.startedAt ? { startedAt: e.startedAt } : {}, ...e.source ? { source: e.source } : {}, ...e.agent ? { agent: e.agent } : {} }).replace(/-->/g, "--\\u003e")} -->`
3004
3023
  );
3005
3024
  return lines.join("\n");
3006
3025
  }
@@ -3420,6 +3439,8 @@ function explorationSummary(p, _owner, _repo, s) {
3420
3439
  status: explorationStatus({ state: p.state, labels: p.labels, headRef: p.headRef, body: p.body }),
3421
3440
  draft: p.draft,
3422
3441
  author: e?.author ?? p.author,
3442
+ ...e?.source ? { source: e.source } : {},
3443
+ ...e?.agent ? { agent: e.agent } : {},
3423
3444
  updatedAt: p.updatedAt,
3424
3445
  headSha: p.headSha,
3425
3446
  previews: previewLinks(s.apps, { branch: p.headRef, pr: p.number, sha: p.headSha })
@@ -5856,6 +5877,8 @@ async function startExploration(ctx, a) {
5856
5877
  ...a.useCase ? { useCase: a.useCase } : {},
5857
5878
  ...a.experimental?.length ? { experimental: a.experimental } : {},
5858
5879
  ...a.author ? { author: a.author } : {},
5880
+ ...a.source ? { source: a.source } : {},
5881
+ ...a.agent ? { agent: a.agent } : {},
5859
5882
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
5860
5883
  };
5861
5884
  const gh = await ctx.github().catch(() => null);
@@ -7189,7 +7212,7 @@ async function writeDrafts(ctx, a) {
7189
7212
  }
7190
7213
 
7191
7214
  // src/server.ts
7192
- var VERSION = true ? "0.3.0" : "dev";
7215
+ var VERSION = true ? "0.3.1" : "dev";
7193
7216
  var ok = (data) => ({ content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] });
7194
7217
  var fail = (e) => ({ content: [{ type: "text", text: `Error: ${e.message ?? String(e)}` }], isError: true });
7195
7218
  var run = (fn) => async (a) => {
@@ -7683,7 +7706,7 @@ function createServer(ctx) {
7683
7706
  },
7684
7707
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true }
7685
7708
  },
7686
- run((a) => startExploration(ctx, a))
7709
+ run((a) => startExploration(ctx, { ...a, source: "mcp" }))
7687
7710
  );
7688
7711
  server.registerTool(
7689
7712
  "bridge_list_explorations",
@@ -1,4 +1,4 @@
1
- import { explorationRules, type ExplorationTryIt } from '@bridge-ds/core';
1
+ import { explorationRules, type ExplorationSource, type ExplorationTryIt } from '@bridge-ds/core';
2
2
  import { BridgeContext } from './context.js';
3
3
  /** `explore/<slug>` from a branch, a slug or a name; throws with how to fix it when it cannot be one. */
4
4
  export declare function toExplorationBranch(ref: string): string;
@@ -8,6 +8,9 @@ export interface StartExplorationInput {
8
8
  useCase?: string | undefined;
9
9
  experimental?: string[] | undefined;
10
10
  author?: string | undefined;
11
+ /** Where it is started from (the MCP tool says mcp, the CLI says cli), and the AI agent behind it when known. */
12
+ source?: ExplorationSource | undefined;
13
+ agent?: string | undefined;
11
14
  dryRun?: boolean | undefined;
12
15
  }
13
16
  /**
@@ -106,6 +109,8 @@ export declare function listExplorations(ctx: BridgeContext, a?: {
106
109
  status: import("@bridge-ds/core").ExplorationStatus;
107
110
  draft: boolean;
108
111
  author: string;
112
+ source?: ExplorationSource | undefined;
113
+ agent?: string | undefined;
109
114
  updatedAt: string;
110
115
  headSha: string;
111
116
  previews: {
@@ -135,6 +140,8 @@ export declare function listExplorations(ctx: BridgeContext, a?: {
135
140
  status: import("@bridge-ds/core").ExplorationStatus;
136
141
  draft: boolean;
137
142
  author: string;
143
+ source?: ExplorationSource | undefined;
144
+ agent?: string | undefined;
138
145
  updatedAt: string;
139
146
  headSha: string;
140
147
  previews: {
@@ -170,6 +177,8 @@ export declare function listExplorations(ctx: BridgeContext, a?: {
170
177
  status: import("@bridge-ds/core").ExplorationStatus;
171
178
  draft: boolean;
172
179
  author: string;
180
+ source?: ExplorationSource | undefined;
181
+ agent?: string | undefined;
173
182
  updatedAt: string;
174
183
  headSha: string;
175
184
  })[];
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  VERSION,
4
4
  optionsFromArgv,
5
5
  serveStdio
6
- } from "./chunk-GABRGCKY.js";
6
+ } from "./chunk-I3TL76GK.js";
7
7
  import "./chunk-X455XY4E.js";
8
8
 
9
9
  // src/index.ts
package/dist/lib.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  parseDocsReply,
24
24
  requests_exports,
25
25
  serveStdio
26
- } from "./chunk-GABRGCKY.js";
26
+ } from "./chunk-I3TL76GK.js";
27
27
  import {
28
28
  CONFIG_FILE,
29
29
  loadConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridge-ds/mcp",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Bridge MCP server: lets Claude (Claude Code, Claude Desktop or any MCP client) read, check and propose changes to a DTCG design system repo through pull requests.",
6
6
  "license": "MIT",
@@ -54,8 +54,8 @@
54
54
  "build:package": "node ../../scripts/build-packages.mjs mcp"
55
55
  },
56
56
  "dependencies": {
57
- "@bridge-ds/core": "^0.3.0",
58
- "@bridge-ds/visual": "^0.2.1",
57
+ "@bridge-ds/core": "^0.4.0",
58
+ "@bridge-ds/visual": "^0.2.2",
59
59
  "@modelcontextprotocol/sdk": "1.31.0",
60
60
  "typescript": "5.9.3",
61
61
  "zod": "3.25.76"