Skip to main content
Glama

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
NameRequiredDescriptionDefault
dependencyYesClojars dependency name in format "group/artifact" (e.g. "metosin/reitit")
versionYesVersion to check (e.g. "0.7.2")

Implementation Reference

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

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

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/Clojars-MCP-Server'

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