connect
Establish a connection to an nREPL server by specifying host and port to evaluate Clojure code, inspect namespaces, and check connection statuses.
Instructions
Connect to an nREPL server. Example: (connect {:host "localhost" :port 1234})
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | nREPL server host | |
| port | Yes | nREPL server port |
Implementation Reference
- src/index.ts:188-211 (handler)The handler function for the 'connect' MCP tool. It validates the input arguments (host and port), closes any existing nREPL connection, stores the host/port, creates a new NReplClient instance, clones an initial session, and returns a success message.case 'connect': { const args = request.params.arguments; if (!args || typeof args.host !== 'string' || typeof args.port !== 'number') { throw new McpError( ErrorCode.InvalidParams, 'host and port parameters are required' ); } // Close existing connection if any if (this.nreplClient) { await this.nreplClient.close(); this.nreplClient = null; } this.host = args.host; this.port = args.port; this.nreplClient = new NReplClient(this.port); await this.nreplClient.clone(); // Create initial session return { content: [{ type: 'text', text: `Connected to nREPL server at ${this.host}:${this.port}` }], }; }
- src/index.ts:143-150 (schema)Input schema definition for the 'connect' tool, specifying host (string) and port (number) as required properties.inputSchema: { type: 'object', properties: { host: { type: 'string', description: 'nREPL server host' }, port: { type: 'number', description: 'nREPL server port' } }, required: ['host', 'port'] }
- src/index.ts:139-151 (registration)Registration of the 'connect' tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'connect', description: 'Connect to an nREPL server.\n' + 'Example: (connect {:host "localhost" :port 1234})', inputSchema: { type: 'object', properties: { host: { type: 'string', description: 'nREPL server host' }, port: { type: 'number', description: 'nREPL server port' } }, required: ['host', 'port'] } },