Skip to main content
Glama

get_user

Retrieve Mantis user details by inputting a username, facilitating quick access to user information within the Mantis Bug Tracker system.

Instructions

根據用戶名稱查詢 Mantis 用戶

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes用戶名稱

Implementation Reference

  • src/server.ts:173-184 (registration)
    Registers the "get_user" MCP tool on the McpServer, including name, description, input schema (username), and handler function.
      "get_user",
      "根據用戶名稱查詢 Mantis 用戶",
      {
        username: z.string().describe("用戶名稱")
      },
      async (params) => {
        return withMantisConfigured("get_user", async () => {
          const user = await mantisApi.getUserByUsername(params.username);
          return JSON.stringify(user, null, 2);
        });
      }
    );
  • The handler function that executes the tool logic: checks Mantis config, fetches user by username via mantisApi, and returns JSON string.
    async (params) => {
      return withMantisConfigured("get_user", async () => {
        const user = await mantisApi.getUserByUsername(params.username);
        return JSON.stringify(user, null, 2);
      });
    }
  • Input schema validation using Zod, requiring a 'username' string parameter.
    {
      username: z.string().describe("用戶名稱")
    },
  • Helper function implementing the core API call to Mantis to get user by username, with caching and error handling.
    async getUserByUsername(username: string): Promise<User> {
      const cacheKey = `user_${username}`;
      const cached = this.cache.get(cacheKey);
      
      if (cached && Date.now() - cached.timestamp < 300000) {
        return cached.data;
      }
    
      try {
        const response = await this.api.get(`/users/username/${encodeURIComponent(username)}`);
        const user = response.data;
    
        this.cache.set(cacheKey, {
          data: user,
          timestamp: Date.now()
        });
    
        return user;
      } catch (error) {
        if (error instanceof MantisApiError) {
          throw error;
        }
        if (error instanceof Error) {
          throw new MantisApiError(`獲取用戶資訊失敗: ${error.message}`);
        }
        throw new MantisApiError('獲取用戶資訊失敗');
      }
    }

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

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