check_clojars_version_exists
Verify the existence of a specific version of a Clojars dependency to ensure its availability for your project.
Instructions
Check if a specific version of a Clojars dependency exists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dependency | Yes | Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit") | |
| version | Yes | Version to check (e.g. "0.7.2") |
Implementation Reference
- src/index.ts:189-244 (handler)Executes the tool logic: validates input, fetches maven-metadata.xml from Clojars, parses versions, checks if specified version exists, returns JSON result or error.} else if (request.params.name === 'check_clojars_version_exists') { if (!isValidVersionCheckArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments. Expected "dependency" in format "group/artifact" and "version"' ); } const [group, artifact] = request.params.arguments.dependency.split('/'); const version = request.params.arguments.version; try { const response = await this.axiosInstance.get<string>( `/${group.replace(/\./g, '/')}/${artifact}/maven-metadata.xml` ); // Extract all versions from XML const versionsMatch = response.data.match(/<version>(.*?)<\/version>/g); const versions = versionsMatch?.map(v => v.replace(/<\/?version>/g, '')) || []; const exists = versions.includes(version); return { content: [ { type: 'text', text: JSON.stringify( { dependency: `${group}/${artifact}`, version: version, exists: exists }, 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:90-107 (registration)Registers the tool in the ListTools response, including name, description, and input schema.{ name: 'check_clojars_version_exists', description: 'Check if a specific version of a Clojars dependency exists', inputSchema: { type: 'object', properties: { dependency: { type: 'string', description: 'Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit")', }, version: { type: 'string', description: 'Version to check (e.g. "0.7.2")', }, }, required: ['dependency', 'version'], }, },
- src/index.ts:93-106 (schema)Input schema definition for the tool parameters: dependency (group/artifact) and version.inputSchema: { type: 'object', properties: { dependency: { type: 'string', description: 'Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit")', }, version: { type: 'string', description: 'Version to check (e.g. "0.7.2")', }, }, required: ['dependency', 'version'], },
- src/index.ts:25-30 (helper)Helper function to validate the tool's input arguments (dependency format and version string).const isValidVersionCheckArgs = (args: any): args is { dependency: string; version: string } => typeof args === 'object' && args !== null && typeof args.dependency === 'string' && args.dependency.includes('/') && typeof args.version === 'string';