Skip to main content
Glama

Get MantisBT Version

get_mantis_version
Read-onlyIdempotent

Retrieves the version of the connected MantisBT installation and optionally checks for the latest official release on GitHub.

Instructions

Returns the version of the connected MantisBT installation and optionally compares it against the latest official release on GitHub.

The version is read from the X-Mantis-Version response header sent by every API call. The GitHub comparison requires an outbound HTTPS request to the GitHub API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
check_latestNoWhether to fetch the latest release from GitHub and compare (default: true)

Implementation Reference

  • The async handler function for the 'get_mantis_version' tool. It calls client.getVersion() to get the installed version from the X-Mantis-Version response header, optionally fetches the latest release from GitHub via VersionHintService, parses and compares versions, and returns a JSON result with status (up-to-date, update-available, newer-than-release, or unknown).
      async ({ check_latest }) => {
        try {
          const installedRaw = await client.getVersion();
          const result: Record<string, unknown> = { installed_version: installedRaw };
    
          if (check_latest) {
            versionHint.triggerLatestVersionFetch();
            const latestRaw = await versionHint.waitForLatestVersion(5000);
    
            result.latest_version = latestRaw;
    
            if (latestRaw === null) {
              result.status = 'unknown';
              result.github_note = 'Could not fetch latest version from GitHub (timeout or network error).';
            } else {
              const installed = parseVersion(installedRaw);
              const latest = parseVersion(latestRaw);
              if (installed && latest) {
                const cmp = compareVersions(installed, latest);
                result.status = cmp === 0
                  ? 'up-to-date'
                  : cmp > 0
                    ? 'newer-than-release'
                    : 'update-available';
              } else {
                result.status = 'unknown';
              }
            }
          }
    
          return {
            content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
          };
        } catch (error) {
          const msg = error instanceof Error ? error.message : String(error);
          return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
        }
      }
    );
  • Tool registration and input schema for 'get_mantis_version'. Defines the tool name, title, description, annotations (readOnly, non-destructive, idempotent), and inputSchema with an optional 'check_latest' boolean parameter (default: true) that controls whether to compare against the latest GitHub release.
        'get_mantis_version',
        {
          title: 'Get MantisBT Version',
          description: `Returns the version of the connected MantisBT installation and optionally compares it against the latest official release on GitHub.
    
    The version is read from the X-Mantis-Version response header sent by every API call.
    The GitHub comparison requires an outbound HTTPS request to the GitHub API.`,
          inputSchema: z.object({
            check_latest: z.preprocess(coerceBool, z.boolean()).default(true).describe(
              'Whether to fetch the latest release from GitHub and compare (default: true)'
            ),
          }),
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
          },
        },
  • src/index.ts:78-78 (registration)
    Registration call that wires up the version tools (including get_mantis_version) into the MCP server. Called from the main createMcpServer() function with the server, client, versionHint service, and mcpVersion.
    registerVersionTools(server, client, versionHint, version);
  • MantisClient.getVersion() — makes a GET request to 'users/me' and extracts the MantisBT version from the X-Mantis-Version response header. Returns the header value or 'unknown'.
      async getVersion(): Promise<string> {
        const response = await fetch(await this.buildUrl('users/me'), {
          method: 'GET',
          headers: await this.headers(),
          signal: AbortSignal.timeout(MantisClient.TIMEOUT_MS),
        });
        if (!response.ok) {
          throw new MantisApiError(response.status, response.statusText);
        }
        return response.headers.get('X-Mantis-Version') ?? 'unknown';
      }
    }
  • VersionHintService class used by the tool to fetch and cache the latest MantisBT version from GitHub tags. Includes triggerLatestVersionFetch() to start an async fetch, waitForLatestVersion() to block up to 5s waiting for the result, and parseVersion()/compareVersions() utilities for version comparison.
    export class VersionHintService {
      private installedVersion: string | null = null;
      private latestVersion: string | null = null;
      private fetchStarted = false;
    
      /** Called by MantisClient after every successful API response. */
      onSuccessfulResponse(response: Response): void {
        if (!this.installedVersion) {
          const v = response.headers.get('X-Mantis-Version');
          if (v) this.installedVersion = v;
        }
      }
    
      /**
       * Starts the GitHub fetch exactly once (fire-and-forget).
       * Safe to call multiple times — subsequent calls are no-ops.
       */
      triggerLatestVersionFetch(): void {
        if (this.fetchStarted) return;
        this.fetchStarted = true;
        void this.doFetch();
      }
    
      private async doFetch(): Promise<void> {
        try {
          const resp = await fetch(MANTISBT_TAGS_URL, {
            headers: {
              'Accept': 'application/vnd.github+json',
              'User-Agent': 'mantisbt-mcp-server',
            },
          });
          if (!resp.ok) return;
          const tags = await resp.json() as Array<{ name: string }>;
          const tag = tags.find(t => /^release-\d+\.\d+\.\d+$/.test(t.name));
          this.latestVersion = tag ? tag.name.replace('release-', '') : null;
        } catch {
          // Network error — no hint, no crash
        }
      }
    
      /**
       * Returns an update hint string if a newer version is known, or null.
       * Never blocks — returns null while the GitHub fetch is still in flight.
       */
      getUpdateHint(): string | null {
        if (!this.installedVersion || !this.latestVersion) return null;
        const installed = parseVersion(this.installedVersion);
        const latest = parseVersion(this.latestVersion);
        if (!installed || !latest) return null;
        if (compareVersions(installed, latest) < 0) {
          return (
            `Note: MantisBT ${this.latestVersion} is available ` +
            `(installed: ${this.installedVersion}) — updating may resolve this issue.`
          );
        }
        return null;
      }
    
      getInstalledVersion(): string | null { return this.installedVersion; }
      getLatestVersion(): string | null { return this.latestVersion; }
    
      /**
       * Waits up to `timeoutMs` for the GitHub fetch to complete.
       * Used by the get_mantis_version tool where blocking is acceptable.
       */
      async waitForLatestVersion(timeoutMs = 5000): Promise<string | null> {
        if (this.latestVersion !== null) return this.latestVersion;
        if (!this.fetchStarted) return null;
        const deadline = Date.now() + timeoutMs;
        while (Date.now() < deadline) {
          if (this.latestVersion !== null) return this.latestVersion;
          await new Promise(r => setTimeout(r, 100));
        }
        return null;
      }
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true. The description adds context beyond annotations: the version is read from the X-Mantis-Version response header, and the GitHub comparison requires an outbound HTTPS request. This clarifies the behavior without contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two short paragraphs, front-loading the main purpose. Every sentence adds value, and there is no redundancy or unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and no output schema, the description fully covers the version retrieval mechanism and optional comparison. It is complete given the complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a well-described boolean parameter 'check_latest'. The description mentions the GitHub comparison but does not add significant semantic detail beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool returns the version of the connected MantisBT installation and optionally compares it to the latest official release. This verb+resource combination is clear and distinguishes it from sibling tools like 'get_mcp_version' or 'get_config'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for version checking, but does not provide explicit guidance on when to use this tool versus alternatives or any prerequisites. However, given the specificity, an agent can infer its purpose without confusion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/dpesch/mantisbt-mcp-server'

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