get_clojars_history
Retrieve version history for a Clojars dependency, specifying the number of versions to return, up to a maximum of 100, for tracking library updates.
Instructions
Get version history of a Clojars dependency
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dependency | Yes | Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit") | |
| limit | No | Number of versions to return (default: 15, max: 100) |
Implementation Reference
- src/index.ts:245-300 (handler)The main handler for the 'get_clojars_history' tool. Validates input, fetches maven-metadata.xml from Clojars, extracts all versions, slices the most recent 'limit' (default 15), reverses to chronological order, and returns JSON with versions, total count, and shown count. Handles 404 and other errors.} else if (request.params.name === 'get_clojars_history') { if (!isValidHistoryArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments. Expected "dependency" in format "group/artifact" and optional "limit" (1-100)' ); } const [group, artifact] = request.params.arguments.dependency.split('/'); const limit = request.params.arguments.limit || 15; try { const response = await this.axiosInstance.get<string>( `/${group.replace(/\./g, '/')}/${artifact}/maven-metadata.xml` ); const versionsMatch = response.data.match(/<version>(.*?)<\/version>/g); const allVersions = versionsMatch?.map(v => v.replace(/<\/?version>/g, '')) || []; const versions = allVersions.slice(-limit).reverse(); return { content: [ { type: 'text', text: JSON.stringify( { dependency: `${group}/${artifact}`, versions: versions, total_versions: allVersions.length, showing: versions.length }, null, 2 ), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { const message = error.response?.status === 404 ? `Dependency ${group}/${artifact} not found on Clojars` : `Clojars API error: ${error.message}`; return { content: [ { type: 'text', text: message, }, ], isError: true, }; } throw error; }
- src/index.ts:108-127 (registration)Registration of the 'get_clojars_history' tool in the MCP server's tool list, including name, description, and input schema definition.{ name: 'get_clojars_history', description: 'Get version history of a Clojars dependency', inputSchema: { type: 'object', properties: { dependency: { type: 'string', description: 'Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit")', }, limit: { type: 'number', description: 'Number of versions to return (default: 15, max: 100)', minimum: 1, maximum: 100, }, }, required: ['dependency'], }, },
- src/index.ts:32-37 (schema)Type guard and validation function for the input arguments of the 'get_clojars_history' tool, ensuring correct dependency format and optional limit constraints.const isValidHistoryArgs = (args: any): args is { dependency: string; limit?: number } => typeof args === 'object' && args !== null && typeof args.dependency === 'string' && args.dependency.includes('/') && (args.limit === undefined || (typeof args.limit === 'number' && args.limit > 0 && args.limit <= 100));