Skip to main content
Glama
JohanCodinha

nREPL MCP Server

by JohanCodinha

eval_form

Evaluate Clojure code within a specified namespace to test functions, reload code, or manage dependencies in an nREPL environment.

Instructions

Evaluate Clojure code in a specific namespace or the current one. Examples:

  • Define and call a function: {"code": "(defn greet [name] (str "Hello, " name "!"))(greet "World"))"}

  • Reload code: {"code": "(clj-reload.core/reload)"}

  • Evaluate in a specific namespace: {"code": "(clojure.repl.deps/sync-deps)", "ns": "user"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesClojure code to evaluate
nsNoOptional namespace to evaluate in. Changes persist for subsequent evaluations.

Implementation Reference

  • The handler for the 'eval_form' tool. Ensures an nREPL client is connected, validates input arguments, optionally switches to the specified namespace, evaluates the provided Clojure code via the nREPL client, and returns the evaluation result as text content.
    case 'eval_form': {
      await this.ensureNReplClient();
      const args = request.params.arguments;
      if (!args || typeof args.code !== 'string') {
        throw new McpError(
          ErrorCode.InvalidParams,
          'code parameter must be a string'
        );
      }
    
      let result: string;
      if (args.ns) {
        // If namespace is provided, change to it first
        await this.nreplClient!.eval(`(in-ns '${args.ns})`);
        result = await this.nreplClient!.eval(args.code);
      } else {
        result = await this.nreplClient!.eval(args.code);
      }
    
      return {
        content: [{ type: 'text', text: result }],
      };
    }
  • src/index.ts:152-166 (registration)
    Registration of the 'eval_form' tool in the ListTools response, including its name, description, and input schema definition for validation.
    {
      name: 'eval_form',
      description: 'Evaluate Clojure code in a specific namespace or the current one. Examples:\n' +
        '- Define and call a function: {"code": "(defn greet [name] (str \\"Hello, \\" name \\"!\\"))(greet \\"World\\"))"}\n' +
        '- Reload code: {"code": "(clj-reload.core/reload)"}\n' +
        '- Evaluate in a specific namespace: {"code": "(clojure.repl.deps/sync-deps)", "ns": "user"}',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: 'Clojure code to evaluate' },
          ns: { type: 'string', description: 'Optional namespace to evaluate in. Changes persist for subsequent evaluations.' },
        },
        required: ['code'],
      },
    },
  • Input schema for the 'eval_form' tool, defining the expected parameters: 'code' (required string) and optional 'ns' (string). Used for validation in tool calls.
    inputSchema: {
      type: 'object',
      properties: {
        code: { type: 'string', description: 'Clojure code to evaluate' },
        ns: { type: 'string', description: 'Optional namespace to evaluate in. Changes persist for subsequent evaluations.' },
      },
      required: ['code'],
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that namespace changes 'persist for subsequent evaluations,' which is useful behavioral context. However, it lacks details on error handling, side effects, or performance implications, leaving gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with a clear purpose statement followed by specific examples. Each sentence earns its place by illustrating use cases without unnecessary elaboration, making it efficient and easy to understand.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (evaluating code with potential side effects), no annotations, and no output schema, the description is moderately complete. It covers purpose and usage examples but lacks details on return values, error formats, or security considerations, which are important for a code evaluation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('code' and 'ns'). The description adds value by providing examples that illustrate parameter usage, such as showing code snippets and namespace context, but does not add new semantic details beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Evaluate Clojure code in a specific namespace or the current one.' It specifies the verb ('evaluate'), resource ('Clojure code'), and scope ('specific namespace or the current one'), distinguishing it from sibling tools like 'connect' and 'get_ns_vars' which likely serve different functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for usage through examples, such as defining functions, reloading code, and evaluating in a namespace. However, it does not explicitly state when to use this tool versus alternatives like 'get_ns_vars' or any exclusions, leaving some ambiguity in tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JohanCodinha/nrepl-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server