Skip to main content
Glama

agda-mcp

MCP server for Agda, providing type checking, go-to-definition, case splitting, auto proof search, and more — directly from Claude Code or any MCP client.

Talks to agda --interaction-json (the same interface powering agda-mode in Emacs/VS Code), so it has access to all of Agda's interactive features without needing agda-language-server.

Installation

Prerequisites

  • Agda (tested with 2.8.0) — agda must be on your PATH

  • uv

1. Clone and build

git clone https://github.com/DreamLinuxer/agda-mcp.git
cd agda-mcp
uv sync

2. Add to your MCP client

Claude Code (globally, for all projects):

claude mcp add --scope user agda-lsp -- uv run --directory /path/to/agda-mcp agda-mcp

Other MCP clients — add to your client's MCP config:

{
  "mcpServers": {
    "agda-lsp": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/agda-mcp", "agda-mcp"],
      "type": "stdio"
    }
  }
}

Replace /path/to/agda-mcp with the absolute path where you cloned the repo.

Related MCP server: lean-lsp-mcp

Tools

File & navigation

Tool

Description

agda_load

Load/type-check a file, get goals + errors + warnings

agda_hover

Symbol kind + definition site at a position

agda_definition

Go to definition (file:line:col)

Goal manipulation (modify source)

Tool

Description

agda_give

Fill a hole with a complete solution

agda_elaborate_give

Fill a hole with an elaborated solution

agda_refine

Refine a goal (may create new subgoals)

agda_intro

Introduce a constructor or lambda

agda_refine_or_intro

Auto-choose between refine and intro

agda_case_split

Case split on a variable in a goal

agda_auto

Try to automatically solve a goal

agda_solve_one

Solve a goal if determined by unification

Goal inspection

Tool

Description

agda_goal_info

Get the type and context of a goal

agda_goal_type

Get just the type of a goal

agda_context

Get the context (bindings) at a goal

agda_goal_type_context_infer

Goal type + context + inferred type of expr

agda_goal_type_context_check

Goal type + context + check expr against type

agda_infer_in_goal

Infer type of an expression at a goal

agda_compute_in_goal

Normalize an expression at a goal

agda_helper_function

Generate helper function type for a goal

agda_why_in_scope_goal

Explain where a name comes from (at a goal)

agda_module_contents_goal

List module contents (at a goal)

Toplevel commands

Tool

Description

agda_infer

Infer the type of an expression

agda_compute

Normalize/evaluate an expression

agda_why_in_scope

Explain where a name comes from

agda_constraints

Show all unsolved constraints

agda_metas

Show all open goals/meta-variables

agda_search_about

Search for definitions mentioning given names

agda_module_contents

List names exported by a module

agda_solve_all

Solve all goals determined by unification

agda_auto_all

Try to automatically solve all goals

Usage examples

Load and type-check a file

agda_load("/path/to/file.agda")
→ Checked. No errors, warnings, or goals.

Infer a type

agda_infer("/path/to/file.agda", "map")
→ {a b : Set} {n : ℕ} → (a → b) → Vec a n → Vec b n

Evaluate an expression

agda_compute("/path/to/file.agda", "2 + 3")
→ 5

Case split

agda_case_split("/path/to/file.agda", 0, "xs")
→ f [] = ?
  f (x ∷ xs) = ?

Auto-solve a goal

agda_auto("/path/to/file.agda", 0)
→ a , b

How it works

The server spawns a single persistent agda --interaction-json process and communicates via the IOTCM protocol over stdio. File state (highlighting data for go-to-definition, goal types, diagnostics) is cached per file and refreshed on each agda_load call.

Available Tools

30 tools
agda_autoB

Try to automatically solve a goal.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output)

Inputs: goal_id (required), file_path (required). Returns: result

agda_auto_allA

Try to automatically solve all visible goals.

Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file

Inputs: file_path (required). Returns: result

agda_case_splitA

Case split on a variable in a goal. Returns the new clauses.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) variable: The variable name to split on

Inputs: goal_id (required), variable (required), file_path (required). Returns: result

agda_computeA

Normalize (evaluate) an expression.

Args: file_path: Absolute path to the .agda file (for scope) expr: The expression to evaluate (e.g. "add 2 3")

Inputs: expr (required), file_path (required). Returns: result

agda_compute_in_goalA

Normalize (evaluate) an expression in the context of a specific goal.

Unlike agda_compute which works at top level, this evaluates within a goal's local context.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: The expression to evaluate

Inputs: expr (required), goal_id (required), file_path (required). Returns: result

agda_constraintsA

Show all current unsolved constraints.

Useful for debugging type errors or understanding what Agda is stuck on.

Args: file_path: Absolute path to the .agda file

Inputs: file_path (required). Returns: result

agda_contextA

Get the context (available bindings) at a specific goal/hole.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output)

Inputs: goal_id (required), file_path (required). Returns: result

agda_definitionB

Go to the definition of a symbol at a position.

Args: file_path: Absolute path to the .agda file line: Line number (1-based) character: Column number (1-based)

Inputs: line (required), character (required), file_path (required). Returns: result

agda_elaborate_giveA

Fill a goal/hole with an elaborated solution.

Like agda_give, but returns the fully elaborated (normalized) expression. Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: The expression to fill the hole with

Inputs: expr (required), goal_id (required), file_path (required). Returns: result

agda_giveA

Fill a goal/hole with a complete solution.

Agda will check the expression and, if correct, replace the hole in the source file. Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: The expression to fill the hole with

Inputs: expr (required), goal_id (required), file_path (required). Returns: result

agda_goal_infoA

Get the type and context of a specific goal/hole.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output)

Inputs: goal_id (required), file_path (required). Returns: result

agda_goal_typeA

Get the type of a specific goal/hole (without context).

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output)

Inputs: goal_id (required), file_path (required). Returns: result

agda_goal_type_context_checkB

Get goal type, context, and check an expression against the goal type.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: Expression to check against the goal type

Inputs: expr (required), goal_id (required), file_path (required). Returns: result

agda_goal_type_context_inferB

Get goal type, context, and the inferred type of an expression.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: Expression whose type to infer in this goal's context

Inputs: expr (required), goal_id (required), file_path (required). Returns: result

agda_helper_functionA

Generate a helper function type signature for a goal.

The expression should be a partial application like "h x y" where h is the helper name and x, y are arguments. Agda will generate the type signature for h. If empty, uses whatever is in the goal.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: Partial application (e.g. "helper x y")

Inputs: goal_id (required), file_path (required), expr. Returns: result

agda_hoverA

Get type/definition info for a symbol at a position.

Args: file_path: Absolute path to the .agda file line: Line number (1-based) character: Column number (1-based)

Inputs: line (required), character (required), file_path (required). Returns: result

agda_inferA

Infer the type of an expression in the context of a loaded file.

Args: file_path: Absolute path to the .agda file (for scope) expr: The expression to type-check (e.g. "add", "suc zero")

Inputs: expr (required), file_path (required). Returns: result

agda_infer_in_goalA

Infer the type of an expression in the context of a specific goal.

Unlike agda_infer which works at top level, this infers within a goal's local context (with access to locally-bound variables).

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: The expression to type-check

Inputs: expr (required), goal_id (required), file_path (required). Returns: result

agda_introA

Introduce a constructor or lambda abstraction in a goal.

Tries to fill the hole with an appropriate constructor or lambda. Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output)

Inputs: goal_id (required), file_path (required). Returns: result

agda_loadA

Load and type-check an Agda file. Returns goals, errors, and warnings.

This must be called before other commands. Call again after edits to refresh.

Args: file_path: Absolute path to the .agda file

Inputs: file_path (required). Returns: result

agda_metasA

Show all open meta-variables (goals) and their types.

Args: file_path: Absolute path to the .agda file

Inputs: file_path (required). Returns: result

agda_module_contentsB

List the top-level names exported by a module.

Args: file_path: Absolute path to the .agda file module_name: The module name to inspect (e.g. "Data.Nat", "Data.List")

Inputs: file_path (required), module_name (required). Returns: result

agda_module_contents_goalA

List the contents of a module, in the context of a goal.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) module_name: The module or record name to inspect

Inputs: goal_id (required), file_path (required), module_name (required). Returns: result

agda_refineA

Refine a goal by filling it with an expression that may create new subgoals.

If expr is empty, Agda tries to refine using the goal type. Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: Expression to refine with (can be empty)

Inputs: goal_id (required), file_path (required), expr. Returns: result

agda_refine_or_introA

Refine or introduce in a goal (auto-chooses the best action).

Combines refine and intro: tries to refine with the expression if given, otherwise introduces a constructor or lambda. Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) expr: Expression to refine with (can be empty for intro)

Inputs: goal_id (required), file_path (required), expr. Returns: result

agda_search_aboutA

Search for definitions whose type mentions the given names.

Useful for finding relevant lemmas, functions, or constructors.

Args: file_path: Absolute path to the .agda file query: Space-separated names to search for in types

Inputs: query (required), file_path (required). Returns: result

agda_solve_allA

Solve all goals whose solutions have been determined by unification.

Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file

Inputs: file_path (required). Returns: result

agda_solve_oneA

Solve a single goal if its solution has been determined by unification.

Only works if the goal has been fully instantiated (e.g. by constraints). Call agda_load afterwards to refresh goals.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output)

Inputs: goal_id (required), file_path (required). Returns: result

agda_why_in_scopeA

Explain where a name is brought into scope.

Args: file_path: Absolute path to the .agda file name: The name to look up (e.g. "ℕ", "suc", "add")

Inputs: name (required), file_path (required). Returns: result

agda_why_in_scope_goalA

Explain where a name is brought into scope, in the context of a goal.

Like agda_why_in_scope but with access to the goal's local scope.

Args: file_path: Absolute path to the .agda file goal_id: The goal/hole number (from agda_load output) name: The name to look up

Inputs: name (required), goal_id (required), file_path (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 30 tools

    Disambiguation2/5

    Many tools overlap significantly, especially the goal-info variants (agda_goal_info, agda_goal_type, agda_context, agda_goal_type_context_infer, agda_goal_type_context_check) and the top-level vs goal-local pairs (agda_infer vs agda_infer_in_goal, agda_compute vs agda_compute_in_goal, agda_why_in_scope vs agda_why_in_scope_goal). Agents will struggle to choose the correct tool among these near-duplicates.

    Naming Consistency4/5

    All tools use the 'agda_' prefix and lowercase snake_case, with a mostly verb_noun structure (load, case_split, infer, compute, give, refine, intro, solve). A few names deviate (e.g., agda_definition, agda_goal_type_context_infer) but the overall pattern is predictable and consistent.

    Tool Count2/5

    With 30 tools, the server exceeds the 25-tool threshold considered heavy. While the domain of Agda interaction is broad, many tools are redundant variants (e.g., agda_solve_one vs agda_solve_all, agda_auto vs agda_auto_all), suggesting the count could be trimmed without losing functionality.

    Completeness4/5

    The tool set covers the core Agda workflow well: loading files, inspecting goals, case splitting, giving/refining/intro, automatic solving, constraint/meta inspection, and module exploration. Minor gaps exist (e.g., no explicit 'revert' or 'abort' command), but agents can work around these with existing tools.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers