MCP server

Connect your agents to gjalla over MCP: the hosted server by URL, or the local server via the CLI. Plus the session-start protocol and full tool reference.

What is the gjalla MCP server?

The gjalla MCP server wraps the CLI and lets AI coding agents (Claude Code, Cursor, Codex, etc.) query your project’s rules, memory, and skills. It is one of the ways Optimize recommendations reach an agent’s context window, along with the CLI and the agents’ native instruction files. Instead of generating code in isolation, agents can check constraints and recall what other agents learned.

The MCP server reads from the same local cache as the CLI. No separate configuration or API keys needed beyond what gjalla setup already configures.

MCP (Model Context Protocol) is a standard for connecting AI agents to external context sources.

There are two ways to connect: the hosted MCP server (a URL, no install) and the local MCP server (runs via the CLI on your machine). Both expose the same tools.

Hosted MCP: connect by URL

The hosted server is the fastest way in, and the only option for browser-based and managed agents (Claude.ai, Lovable, ChatGPT) that can’t shell out to a local CLI. Add this URL anywhere your tool accepts a remote MCP server:

https://app.gjalla.io/mcp/stream

Per-host setup

  • Claude.ai: Settings → Integrations (or Connectors, depending on plan) → add a custom MCP server with the URL → approve the OAuth request.
  • Claude Code: claude mcp add --transport http gjalla {hostedMcpUrl}, then /mcp to authenticate.
  • Cursor: Settings → Features → MCP (or edit ~/.cursor/mcp.json) → add a server with the URL → choose OAuth and approve in the popup.
  • Lovable: Settings → Integrations → Custom MCP → paste the URL → Connect → approve in the gjalla popup.
  • ChatGPT: open custom-connectors / MCP settings (visibility depends on plan) → add a connector with the URL → approve the OAuth request.

Authentication

OAuth is the default and recommended method: the host opens a gjalla approval popup and receives a short-lived key automatically. Hosts that support pasting a bearer token can use a gjalla API key (gja_...) instead; paste it into the host’s bearer-token field, never into the URL.

Manage and revoke connected hosts anytime under Settings → Integrations. Revoking takes effect immediately.

If you’re an agent, start here

You’re an AI coding agent. Here’s the short version of where, why, and how to use gjalla.

Session-start protocol

First thing in any session, before you start exploring or editing:

get_context(scope="rules")            # the constraints you are working within
get_memories()                        # what earlier sessions learned the hard way
# Then, before editing any file:
get_file_context(file_path="...")     # which rules apply to it

That’s the wake-up routine. Run it once per session and you have the orientation you’d otherwise build up over 5-10 grep and read calls.

Intent → tool

Match your current intent to the right tool. The full reference is below; this is the shortcut.

  • Orient on a new project / resume a session → get_context(scope="rules") + get_memories()
  • About to edit a file → get_file_context(file_path="...")
  • About to design a change → get_context(scope="rules") + get_project_skills()
  • Learned something durable → save_memory, or add_rule / add_skill for a standard or a repeatable procedure
  • Before committing → prepare_attestation() (draft) → prepare_attestation(...) (write)
  • Stuck / empty results → get_status() (config check) or sync() (refresh cache)

Why it’s cheaper than exploring

One get_context(scope="rules") call returns the active constraints. The exploration alternative is finding and reading ADR files and old docs, and grepping for patterns. If you’re optimizing for tokens or for getting it right the first time, the gjalla call wins.

What gjalla knows that you don’t

gjalla holds the things no single file can tell you:

  • Rules and ADRs: constraints other engineers wrote down. You’ll violate them silently otherwise.
  • Cross-session memory: what your past sessions (and other agents’ sessions on this project) learned. Read through get_memories()
  • Skills: repeatable procedures your team has already worked out. Read through get_project_skills().

Attestation: how you prove you did it right

When you commit, gjalla expects an attestation. This isn’t paperwork. It’s the artifact that lets your human collaborator trust your work without re-reading every line. You’re telling them, on the record: I checked these rules, and here is what changed.

The attestation workflow closes a loop you should already be running mentally. One read, one draft and a write:

# 1. Read the rules so you actually know what to attest against.
get_context(scope="rules")

# 2. Draft the attestation (gjalla pre-fills staged files, applicable rules,
#    diff hash, and a template for you).
prepare_attestation()

# 3. Write the final attestation with your self-reported rule status and
#    a summary of the change.
prepare_attestation(
    summary="...",
    rules={"checked": True, "applicable": [...]},
    changes={...},
)

What this gets you as an agent: your work becomes legible. Whoever reviews your work can see at a glance which rules you considered (and whether you flagged anything as remediated or needs-review) and why. Reviews go faster and your trust budget with the team grows over time. The pre-commit hook also catches violations locally so you don’t learn about them from a failed CI run an hour later.

Be honest in the attestation. If you couldn’t determine compliance with a rule, mark it needs-review with a short note. That’s what humans want to see, not a blanket compliant that turns out to be wrong.

Local MCP server: via the CLI

If you have the gjalla CLI installed, this is the fastest way to get set up:

gjalla setup mcp

This auto-detects your editor and writes the MCP config for you. If gjalla is installed locally with the mcp extra, it uses the local binary directly. Otherwise it falls back to uvx for zero-install.

The MCP server is a Python package. Install with pip install gjalla[mcp] for local use, or let uvx handle it automatically.

Manual setup by tool

If you prefer manual setup, add the config below. No API key or env vars needed in the MCP config. The server reads from .gjalla/config.yaml.

Claude Code

MCP configuration

Add to .mcp.json:

{
  "mcpServers": {
    "gjalla": {
      "command": "gjalla",
      "args": ["mcp", "serve"]
    }
  }
}

gjalla setup mcp auto-detects Claude Code and writes this for you.

CLAUDE.md

Add to CLAUDE.md in your project root:

### Rules, memory and skills
Always check with gjalla before implementing: the rules and decisions that must be followed, and what earlier sessions learned.

Use `gjalla rules show` and `gjalla memory show` (CLI) or the gjalla MCP tools to read them first. Report which rules you checked in your attestation.
Cursor

MCP configuration

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "gjalla": {
      "command": "gjalla",
      "args": ["mcp", "serve"]
    }
  }
}

Cursor Rules

Add to .cursor/rules/gjalla.mdc in your project root:

### Rules, memory and skills
Always check with gjalla before implementing: the rules and decisions that must be followed, and what earlier sessions learned.

Use `gjalla rules show` and `gjalla memory show` (CLI) or the gjalla MCP tools to read them first. Report which rules you checked in your attestation.
Codex (OpenAI)

MCP configuration

Add to .mcp.json:

{
  "mcpServers": {
    "gjalla": {
      "command": "gjalla",
      "args": ["mcp", "serve"]
    }
  }
}

Agent Instructions

Add to AGENTS.md in your project root:

### Rules, memory and skills
Always check with gjalla before implementing: the rules and decisions that must be followed, and what earlier sessions learned.

Use `gjalla rules show` and `gjalla memory show` (CLI) or the gjalla MCP tools to read them first. Report which rules you checked in your attestation.

Using uvx (no local install)

If gjalla isn’t installed locally, use uvx instead:

{
  "mcpServers": {
    "gjalla": {
      "command": "uvx",
      "args": ["--with", "gjalla[mcp]", "gjalla", "mcp", "serve"]
    }
  }
}

Available MCP tools

Context & discovery

get_context

When: start of any session, or when you need project rules or context.

Params: optional scope (rules, tech_stack, system, and others) and path for dot-notation drill-down.

Returns: overview with entry counts, or full detail for the requested scope/path.

This is your primary orientation tool. Call it first in every session.
get_file_context

When: before editing a file. See which rules apply to it.

Returns: applicable rules and relevant facts for the file.

get_status

When: troubleshooting empty results or checking configuration.

Returns: git repo status, API key, project link, cache health, and actionable next steps.

Attestation

prepare_attestation

When: two-phase commit attestation workflow.

Phase 1: call with no args to get a draft: staged files, applicable rules, diff hash, and a template.

Phase 2: call with summary, rules, and changes to write the final .gjalla/.commit-attestation.yaml.

Skills & memories

get_project_skills

When: check available skills before starting work, or find skills for a specific workflow.

Params: optional category (context, governance, testing, workflow, etc.) and persona (code-reviewer, architect, etc.).

Returns: the resolved set of enabled skills: platform defaults + system overrides + your project customizations merged together.

CLI equivalent: gjalla skills show.

get_memories

When: retrieve durable knowledge explicitly saved in Gjalla.

Params: scope and scopeId, plus optional category, sourceAgent, tag, key, search, resolved, and status filters.

Returns: { memories, facets }. Project scope resolves team → system → project by default.

CLI equivalent: gjalla memory show

Cross-project (systems)

discover_systems

When: finding available systems and their IDs (needed for other system tools).

Returns: systems accessible with your API key, filtered by project access.

get_system_context

When: understanding how this project fits within the broader system.

Returns: system-level context including sibling projects and their roles.

discover_projects

When: listing available projects or finding one to connect to.

Management

setup

When: first time in a repo. Initialize gjalla, save API key, link project.

Params: optional api_key and project_id. Auto-syncs when fully configured.

sync

When: need fresh data or after connecting a project.

Returns: upload results for pending attestations and refreshed cache status.

add_rule

When: adding a principle, process, decision, check, or constraint.

Params: rule_type (principle | process | adr | check | constraint, default check), name, description, plus scope and scopeId.

add_skill

When: capturing a repeatable procedure so every agent reuses it instead of being re-told.

Params: name, content, plus scope and scopeId.

Choosing a scope

add_rule, add_skill, and save_memory all take the same scope / scopeId pair, so pick by who the thing is actually for. A team-wide standard belongs at team scope rather than copied into each codebase.

  • Team: scope="team". Omit scopeId and it targets the team on your credential, so you never need a lookup call first. Requires team-admin.
  • System: scope="system" with an explicit scopeId.
  • Project: the default. Uses the connected project unless you pass a scopeId.
  • Personal: local server only, when signed out. Writes to ~/.gjalla/user/ and never reaches the network.

Resolution runs lowest to highest: platform, then team, then system, then project, with the more specific scope overriding.

CLI equivalents

The MCP server wraps the CLI. Agents can use either; the CLI is faster for simple lookups.

  • get_context(scope="rules") → gjalla rules show
  • get_memories() → gjalla memory show
  • get_project_skills() → gjalla skills show
  • sync() → gjalla sync