Skip to main content
Glama

get_clojars_latest_version

Retrieve the current version of a Clojars dependency using the Clojars-MCP-Server, providing accurate dependency information for Clojure projects.

Instructions

Get the latest version of a Clojars dependency (Maven artifact)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dependencyYesClojars dependency name in format "group/artifact" (e.g. "metosin/reitit")

Implementation Reference

  • The handler for the 'get_clojars_latest_version' tool. Validates input, fetches Maven metadata XML from Clojars, parses latest version using regex, returns JSON with version or error message.
    if (request.params.name === 'get_clojars_latest_version') {
      if (!isValidDependencyArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid dependency format. Expected "group/artifact" (e.g. "metosin/reitit")'
        );
      }
    
      const [group, artifact] = request.params.arguments.dependency.split('/');
    
      try {
        const response = await this.axiosInstance.get<string>(
          `/${group.replace(/\./g, '/')}/${artifact}/maven-metadata.xml`
        );
    
        // Extract latest version from XML
        const versionMatch = response.data.match(/<latest>(.*?)<\/latest>/);
        const releaseMatch = response.data.match(/<release>(.*?)<\/release>/);
        const latestVersion = releaseMatch?.[1] || versionMatch?.[1];
    
        if (!latestVersion) {
          throw new Error('Could not find version information in metadata');
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  dependency: `${group}/${artifact}`,
                  latest_version: latestVersion
                },
                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;
      }
    } else if (request.params.name === 'check_clojars_version_exists') {
  • src/index.ts:76-89 (registration)
    Registration of the tool in the ListTools response, including name, description, and input schema.
    {
      name: 'get_clojars_latest_version',
      description: 'Get the latest version of a Clojars dependency (Maven artifact)',
      inputSchema: {
        type: 'object',
        properties: {
          dependency: {
            type: 'string',
            description: 'Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit")',
          },
        },
        required: ['dependency'],
      },
    },
  • Input schema for validating the tool's arguments: requires 'dependency' as string in 'group/artifact' format.
    inputSchema: {
      type: 'object',
      properties: {
        dependency: {
          type: 'string',
          description: 'Clojars dependency name in format "group/artifact" (e.g. "metosin/reitit")',
        },
      },
      required: ['dependency'],
    },
  • Helper function to validate the dependency argument format before processing.
    const isValidDependencyArgs = (args: any): args is { dependency: string } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.dependency === 'string' &&
      args.dependency.includes('/');
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