connect
Establish a connection to an nREPL server by specifying host and port parameters to enable Clojure code evaluation and namespace inspection.
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)Handler for the 'connect' tool: validates input arguments, closes existing connection if any, initializes a new NReplClient with the provided host and port, clones a 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-149 (schema)Input schema definition for the 'connect' tool, specifying host as string and port as number, both required.inputSchema: { type: 'object', properties: { host: { type: 'string', description: 'nREPL server host' }, port: { type: 'number', description: 'nREPL server port' } }, required: ['host', 'port']
- src/index.ts:140-151 (registration)Registration of the 'connect' tool in the ListToolsRequestSchema response, 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'] } },