check_maven_version_exists
Verify if a specific version of a Maven dependency exists in the Maven Central Repository. Input the dependency coordinates along with the version to confirm its availability.
Instructions
Check if a specific version of a Maven dependency exists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dependency | Yes | Maven coordinate in format "groupId:artifactId[:version][:packaging][:classifier]" (e.g. "org.springframework:spring-core" or "org.springframework:spring-core:5.3.20:jar") | |
| version | No | Version to check if not included in dependency string |
Implementation Reference
- src/index.ts:292-351 (handler)The handler function that implements the check_maven_version_exists tool. It validates arguments, parses the Maven coordinate, queries the Maven Central API for an exact version match, and returns 'true' or 'false'.private async handleCheckVersionExists(args: unknown) { if (!isValidVersionCheckArgs(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid Maven dependency format' ); } const coord = parseMavenCoordinate(args.dependency); // Use version from coordinate if available, otherwise use the version parameter const version = coord.version || args.version; if (!version) { throw new McpError( ErrorCode.InvalidParams, 'Version must be provided either in dependency string or version parameter' ); } try { let query = `g:"${coord.groupId}" AND a:"${coord.artifactId}" AND v:"${version}"`; if (coord.packaging) { query += ` AND p:"${coord.packaging}"`; } const response = await this.axiosInstance.get<MavenSearchResponse>('', { params: { q: query, core: 'gav', rows: 1, wt: 'json', }, }); const exists = response.data.response.docs.length > 0; return { content: [ { type: 'text', text: exists ? 'true' : 'false', }, ], }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [ { type: 'text', text: `Maven Central API error: ${ error.response?.data?.error?.msg ?? error.message }`, }, ], isError: true, }; } throw error; } }
- src/index.ts:148-161 (schema)The input schema definition for the check_maven_version_exists tool, specifying the expected parameters.inputSchema: { type: 'object', properties: { dependency: { type: 'string', description: 'Maven coordinate in format "groupId:artifactId[:version][:packaging][:classifier]" (e.g. "org.springframework:spring-core" or "org.springframework:spring-core:5.3.20:jar")', }, version: { type: 'string', description: 'Version to check if not included in dependency string', }, }, required: ['dependency'], },
- src/index.ts:145-162 (registration)Registration of the tool in the ListTools handler, including name, description, and schema.{ name: 'check_maven_version_exists', description: 'Check if a specific version of a Maven dependency exists', inputSchema: { type: 'object', properties: { dependency: { type: 'string', description: 'Maven coordinate in format "groupId:artifactId[:version][:packaging][:classifier]" (e.g. "org.springframework:spring-core" or "org.springframework:spring-core:5.3.20:jar")', }, version: { type: 'string', description: 'Version to check if not included in dependency string', }, }, required: ['dependency'], }, },
- src/index.ts:195-196 (registration)Dispatch registration in the CallToolRequestSchema switch statement.case 'check_maven_version_exists': return this.handleCheckVersionExists(request.params.arguments);
- src/index.ts:67-74 (helper)Type guard helper for validating arguments to check_maven_version_exists.const isValidVersionCheckArgs = ( args: any ): args is { dependency: string; version?: string } => typeof args === 'object' && args !== null && typeof args.dependency === 'string' && (args.version === undefined || typeof args.version === 'string');