Skip to content

Global token auth sends wrong header: X-Glean-Act-As instead of X-Glean-ActAs #347

@ryan-macdonald-nb

Description

@ryan-macdonald-nb

Bug Description

When using a global API token with GLEAN_ACT_AS, the MCP server sends the header X-Glean-Act-As (with hyphens between each word), but Glean's API expects X-Glean-ActAs (camelCase "ActAs").

This causes a 400 error:

Required header missing: X-Glean-ActAs
Not allowed

Steps to Reproduce

  1. Set up the MCP server with a global Glean API token:
    export GLEAN_INSTANCE=mycompany
    export GLEAN_API_TOKEN=<global-token>
    export GLEAN_ACT_AS=user@company.com
  2. Make any tool call (e.g., glean-chat or glean-company_search)
  3. The request fails with "Required header missing: X-Glean-ActAs"

Root Cause

In build/common/client.js, line 74:

opts.httpClient = buildHttpClientWithGlobalHeaders({
    'X-Glean-Act-As': actAs,  // ← wrong header name
});

The header should be X-Glean-ActAs (no hyphen between "Act" and "As"), matching what the Glean API expects.

Verification

Tested directly against the Glean API:

  • X-Glean-Act-As: user@company.com400 "Required header missing: X-Glean-ActAs"
  • X-Glean-ActAs: user@company.com200 (works correctly)

Fix

Change line 74 in src/common/client.ts:

- 'X-Glean-Act-As': actAs,
+ 'X-Glean-ActAs': actAs,

Environment

  • @gleanwork/mcp-server version: 0.7.1 (latest)
  • Node.js: v22
  • OS: Linux (GKE pod) / macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions