Skip to main content
Glama

get_issue_by_id

Retrieve detailed information about a Mantis Bug Tracker issue by specifying its unique ID. Integrates with the Mantis MCP Server for efficient bug tracking and data analysis.

Instructions

根據 ID 獲取 Mantis 問題詳情

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueIdYes問題 ID

Implementation Reference

  • Core handler function that fetches the specific issue by ID from the Mantis API endpoint `/issues/${issueId}`, with logging and caching via cachedRequest.
    async getIssueById(issueId: number): Promise<Issue> {
      log.info('獲取問題詳情', { issueId });
      
      const cacheKey = `issue-${issueId}`;
      
      return this.cachedRequest<Issue>(cacheKey, () => {
        return this.api.get(`/issues/${issueId}`);
      });
    }
  • src/server.ts:157-169 (registration)
    MCP tool registration using McpServer.tool, defining the tool name, description, input schema (issueId), and handler that wraps mantisApi.getIssueById with configuration check and JSON serialization.
    server.tool(
      "get_issue_by_id",
      "根據 ID 獲取 Mantis 問題詳情",
      {
        issueId: z.number().describe("問題 ID"),
      },
      async ({ issueId }) => {
        return withMantisConfigured("get_issue_by_id", async () => {
          const issue = await mantisApi.getIssueById(issueId);
          return JSON.stringify(issue, null, 2);
        });
      }
    );
  • TypeScript interface defining the structure of the Issue object returned by the getIssueById handler, serving as output schema.
    export interface Issue {
      id: number;
      summary: string;
      description: string;
      status: {
        id: number;
        name: string;
      };
      project: {
        id: number;
        name: string;
      };
      category: {
        id: number;
        name: string;
      };
      reporter: {
        id: number;
        name: string;
        email: string;
      };
      handler?: {
        id: number;
        name: string;
        email: string;
      };
      priority?: {
        id: number;
        name: string;
      };
      severity?: {
        id: number;
        name: string;
      };
      created_at: string;
      updated_at: string;
    }
  • Zod input schema for the tool, validating the issueId parameter.
    {
      issueId: z.number().describe("問題 ID"),
    },
  • Helper function used by all tools to check Mantis configuration, execute the core action, handle errors, and format MCP-compliant responses.
    async function withMantisConfigured<T>(
      toolName: string,
      action: () => Promise<T>
    ): Promise<{
      [x: string]: unknown;
      content: Array<{
        [x: string]: unknown;
        type: "text";
        text: string;
      }>;
      _meta?: { [key: string]: unknown } | undefined;
      isError?: boolean | undefined;
    }> {
      try {
        // 檢查是否已配置 Mantis API
        if (!isMantisConfigured()) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    error: "Mantis API 尚未配置",
                    message: "請在環境變數中設定 MANTIS_API_URL 和 MANTIS_API_KEY"
                  },
                  null,
                  2
                ),
              },
            ],
            isError: true
          };
        }
    
        // 執行工具邏輯
        const result = await action();
        return {
          content: [
            {
              type: "text",
              text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        // 處理錯誤情況
        let errorMessage = `執行 ${toolName} 時發生錯誤`;
        let logData: LogData = { tool: toolName };
    
        if (error instanceof MantisApiError) {
          errorMessage = `Mantis API 錯誤: ${error.message}`;
          if (error.statusCode) {
            errorMessage += ` (HTTP ${error.statusCode})`;
            logData = { ...logData, statusCode: error.statusCode };
          }
          log.error(errorMessage, { ...logData, error: error.message });
        } else if (error instanceof Error) {
          errorMessage = error.message;
          log.error(errorMessage, { ...logData, error: error.stack });
        } else {
          log.error(errorMessage, { ...logData, error });
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  error: errorMessage,
                },
                null,
                2
              ),
            },
          ],
          isError: true
        };
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it's a read operation ('獲取'), but doesn't mention authentication requirements, rate limits, error handling (e.g., for invalid IDs), or what happens if the issue doesn't exist. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence in Chinese that directly states the tool's function without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. Every part of the sentence contributes to understanding the purpose.

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

Completeness2/5

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

Given the complexity (a read operation with one parameter), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what '詳情' includes in the response, potential errors, or dependencies. For a tool that retrieves data, more context on output and behavior is needed to be fully helpful.

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?

The description adds minimal meaning beyond the input schema, which has 100% coverage and documents the single parameter 'issueId' as a number for the issue ID. The description implies the parameter is used to fetch details, but doesn't provide additional context like format examples or constraints. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

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

Purpose4/5

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

The description clearly states the verb ('獲取' meaning 'get') and resource ('Mantis 問題詳情' meaning 'Mantis issue details'), making the purpose understandable. It distinguishes from siblings like 'get_issues' (which likely lists multiple issues) by specifying retrieval of a single issue by ID. However, it doesn't explicitly mention what '詳情' (details) includes, which could be more specific.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention siblings like 'get_issues' for listing issues or 'get_issue_statistics' for aggregated data, nor does it specify prerequisites such as needing a valid issue ID. Usage is implied by the name but not explicitly stated.

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

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/kfnzero/mantis-mcp-server'

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