import { MavenCoordinate } from '../types.js';
import { fetchMavenMetadata, extractVersions } from '../maven-client.js';
import { isStableVersion } from '../version-utils.js';
export const schema = {
name: 'check_version_exists',
description: 'Verify if a specific version exists for a Maven dependency',
inputSchema: {
type: 'object',
properties: {
dependency: {
type: 'string',
description:
'Maven coordinate in format "groupId:artifactId" (e.g., "org.apache.kafka:kafka-clients")',
},
version: {
type: 'string',
description: 'The version to check (e.g., "3.6.0")',
},
},
required: ['dependency', 'version'],
},
};
export async function handler(coord: MavenCoordinate, version: string) {
const metadata = await fetchMavenMetadata(coord);
const allVersions = extractVersions(metadata);
const exists = allVersions.includes(version);
const isStable = isStableVersion(version);
if (!exists) {
return {
content: [
{
type: 'text',
text: JSON.stringify(
{
exists: false,
version: version,
dependency: `${coord.groupId}:${coord.artifactId}`,
message: `Version ${version} does not exist`,
},
null,
2
),
},
],
};
}
return {
content: [
{
type: 'text',
text: JSON.stringify(
{
exists: true,
version: version,
dependency: `${coord.groupId}:${coord.artifactId}`,
isStable: isStable,
stabilityWarning: isStable
? null
: 'This is a pre-release version',
},
null,
2
),
},
],
};
}