Skip to main content
Glama

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'], },

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