Skip to main content
Glama
snowild

Redmine MCP Server

by snowild

get_user

Retrieve detailed user information from Redmine by providing a user ID to access profile data and account details.

Instructions

取得特定用戶的詳細資訊

Args:
    user_id: 用戶 ID
    
Returns:
    用戶的詳細資訊,以易讀格式呈現

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes

Implementation Reference

  • The primary MCP tool handler for 'get_user'. Decorated with @mcp.tool() for automatic registration. Fetches user data from RedmineClient and formats it into a readable string response.
    @mcp.tool()
    def get_user(user_id: int) -> str:
        """
        取得特定用戶的詳細資訊
        
        Args:
            user_id: 用戶 ID
            
        Returns:
            用戶的詳細資訊,以易讀格式呈現
        """
        try:
            client = get_client()
            user_data = client.get_user(user_id)
            
            # 格式化用戶資訊
            result = f"用戶 #{user_id}: {user_data.get('firstname', '')} {user_data.get('lastname', '')}\n\n"
            result += "基本資訊:\n"
            result += f"- 登入名: {user_data.get('login', 'N/A')}\n"
            result += f"- Email: {user_data.get('mail', 'N/A')}\n"
            result += f"- 狀態: {'啟用' if user_data.get('status', 1) == 1 else '停用'}\n"
            result += f"- 建立時間: {user_data.get('created_on', 'N/A')}\n"
            
            if user_data.get('last_login_on'):
                result += f"- 最後登入: {user_data.get('last_login_on')}\n"
            
            # 群組資訊
            if user_data.get('groups'):
                result += "\n群組:\n"
                for group in user_data['groups']:
                    result += f"- {group.get('name', 'N/A')}\n"
            
            # 自訂欄位
            if user_data.get('custom_fields'):
                result += "\n自訂欄位:\n"
                for field in user_data['custom_fields']:
                    if field.get('value'):
                        result += f"- {field.get('name', 'N/A')}: {field.get('value', 'N/A')}\n"
            
            return result
            
        except RedmineAPIError as e:
            return f"取得用戶資訊失敗: {str(e)}"
        except Exception as e:
            return f"系統錯誤: {str(e)}"
  • RedmineClient helper method that performs the actual API call to retrieve user details by ID from the Redmine server.
    def get_user(self, user_id: int) -> Dict[str, Any]:
        """取得特定用戶詳情"""
        response = self._make_request('GET', f'/users/{user_id}.json')
        
        if 'user' not in response:
            raise RedmineAPIError(f"找不到用戶 ID {user_id}")
        
        return response['user']
  • The @mcp.tool() decorator registers the get_user function as an MCP tool.
    @mcp.tool()

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/snowild/redmine-mcp'

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