Skip to main content
Glama

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
NameRequiredDescriptionDefault
dependencyYesMaven coordinate in format "groupId:artifactId[:version][:packaging][:classifier]" (e.g. "org.springframework:spring-core" or "org.springframework:spring-core:5.3.20:jar")
versionNoVersion to check if not included in dependency string

Implementation Reference

  • 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; } }
  • 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);
  • 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');

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Bigsy/maven-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server