Skip to content

feat(claude): connect Claude Code to Glean directly - #54

Draft
steve-calvert-glean wants to merge 1 commit into
mainfrom
feat/claude-direct-mcp
Draft

steve-calvert-glean wants to merge 1 commit into
mainfrom
feat/claude-direct-mcp

Conversation

@steve-calvert-glean

Copy link
Copy Markdown
Contributor

What this changes

The Claude package stops starting a local MCP server. Claude Code connects to the user's Glean server itself.

  • Server entry. An HTTP entry with url: "${user_config.server_url}" and the header X-Glean-Metadata: claude-code-plugin. server_url is a new required plugin option.
  • One hook. hooks/check-setup.mjs runs on SessionStart and replaces the two hooks that fed the local server.
  • Skills and README. Claude overrides for the skills and README that told users to run the local server's setup.
  • Cursor and Codex. No change. dist/cursor and dist/codex match the published output repos.

What the hook does

State What it does
server_url is set Nothing.
First session after an update from version 3, with a saved URL Sets server_url to that URL, unchanged, by running claude plugin configure. Then tells the user to run /reload-plugins and sign in under /mcp. It does this one time.
No saved URL, or the option was cleared later Tells the user to set the server URL under /plugin.
Claude Code below 2.1.274 Says to run claude update.

It always exits 0 and never reads credentials. It carries the URL over, not the sign-in: the user signs in one time with Claude Code's own OAuth client.

Do not release yet

One thing blocks a release. Glean's /mcp/gateway/proxy endpoint lists set_tool_approval to every client. The local server kept that tool from the model; a direct connection lists it. A model that can call it can save Always Allow and turn off Glean's approval form. A server-side change that stops listing the tool to direct clients is in review. Release after it is deployed, and after a live check shows the tool is gone.

Tested

  • npm run test:bundle passes: 25 test files, 465 tests. The hook has 35 of them.
  • npm test (build and pluginpack validation for all three targets) and npm run typecheck:bundle pass.
  • claude plugin validate --strict dist/claude/plugins/glean passes.
  • Update from 3.6.2 in a scratch marketplace, Claude Code 2.1.319: one plugin. The first session set server_url to the saved URL and printed the message. The next session printed nothing. One sign-in connected the server.
  • Fresh install with nothing saved: the hook printed the message to set the server URL.
  • Live, Claude Code 2.1.319 against a Glean deployment at /mcp/gateway/proxy: connected on MCP 2026-07-28, and the header reached Glean's usage log. A search read returned. A run_tool write showed Glean's form; Allow ran the write. Under claude -p the form was cancelled and the write did not run.
  • Skill evals against a stub shaped like the proxy (see test: add Claude skill evals that compare two plugin builds #53): 35 of 35 for 3.6.2's skills and 35 of 35 for this build. Every case is a read.

Not tested

  • Windows.
  • Project-scope and managed installs. The hook runs claude plugin configure, which may behave differently there.
  • What the /plugin screen and automatic updates show when an update adds the required option.
  • Claude Code at exactly 2.1.274.
  • Chat and Cowork. Cowork loads hooks, so the message that points at /plugin would appear there.

For the reviewer

  • Large discovery responses. In the live run, one find_skills_and_tools response was 154,619 characters. Claude Code saved it to a file and the model read it with jq. It worked. Version 3 wrote skill files to disk instead.
  • Skills name code_search. Several skills and agents mention it, and the proxy endpoint does not serve it. That is true of 3.6.2 as well.
  • READMEs. docs: clarify plugin READMEs for public listings #47 also edits the READMEs. Whichever merges second needs a rebase.
  • Version. This PR does not bump the version. The update test used 3.7.0.

@david-hamilton-glean owns this from here.

The Claude package no longer starts a local MCP server. Its server entry is an
HTTP entry whose URL is a plugin option, server_url, so Claude Code connects to
the user's Glean server itself, signs in with its own OAuth client, and shows
Glean's approval form for writes. Cursor and Codex output is unchanged.

One SessionStart hook, check-setup.mjs, replaces the two hooks that fed the
local server:

- On the first session after an update from version 3, it sets server_url to
  the URL that version saved, unchanged, with `claude plugin configure`. It
  does this one time, then tells the user to run /reload-plugins and sign in.
- With no saved URL, or when the option is cleared later, it tells the user to
  set the server URL under /plugin.
- Below Claude Code 2.1.274 it says to run `claude update`.
- It always exits 0 and never reads credentials.

The server entry sends X-Glean-Metadata: claude-code-plugin so Glean can tell
plugin traffic from a hand-added server.

The two old hooks move to shared/glean/mcp/tests/claude-relay-hooks because the
local server's tests still run them. No package ships them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant