Skip to main content
Glama
snowild

Redmine MCP Server

by snowild

refresh_cache

Manually refresh enumeration values and user caches in Redmine to ensure data consistency and resolve synchronization issues.

Instructions

手動刷新列舉值和用戶快取

Returns:
    刷新結果訊息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'refresh_cache'. Calls RedmineClient.refresh_cache(), reloads cache info, and returns formatted status report with cache statistics.
    @mcp.tool()
    def refresh_cache() -> str:
        """
        手動刷新列舉值和用戶快取
        
        Returns:
            刷新結果訊息
        """
        try:
            client = get_client()
            client.refresh_cache()
            
            # 取得快取資訊
            cache = client._load_enum_cache()
            domain = cache.get('domain', 'N/A')
            cache_time = cache.get('cache_time', 0)
            
            if cache_time > 0:
                cache_datetime = datetime.fromtimestamp(cache_time).strftime('%Y-%m-%d %H:%M:%S')
            else:
                cache_datetime = 'N/A'
            
            result = f"""快取刷新成功!
    
    Domain: {domain}
    快取時間: {cache_datetime}
    
    快取內容統計:
    - 優先權: {len(cache.get('priorities', {}))} 個
    - 狀態: {len(cache.get('statuses', {}))} 個  
    - 追蹤器: {len(cache.get('trackers', {}))} 個
    - 用戶(姓名): {len(cache.get('users_by_name', {}))} 個
    - 用戶(登入名): {len(cache.get('users_by_login', {}))} 個
    
    快取位置: {client._cache_file}"""
            
            return result
            
        except RedmineAPIError as e:
            return f"刷新快取失敗: {str(e)}"
        except Exception as e:
            return f"系統錯誤: {str(e)}"
  • RedmineClient.refresh_cache() method invoked by the tool handler to trigger cache refresh.
    def refresh_cache(self):
        """手動刷新快取"""
        self._refresh_enum_cache()
  • Core cache refresh logic: Fetches priorities, statuses, trackers, time activities, and users from Redmine API; builds name-to-ID mappings; saves to JSON file in ~/.redmine_mcp.
    def _refresh_enum_cache(self):
        """刷新列舉值快取"""
        try:
            # 取得所有列舉值
            priorities = self.get_priorities()
            statuses = self.get_issue_statuses()
            trackers = self.get_trackers()
            time_entry_activities = self.get_time_entry_activities()
            
            # 取得用戶列表(限制100個避免太大)
            users = self.list_users(limit=100)
            
            # 建立名稱到ID的對應
            user_by_name = {}
            user_by_login = {}
            for user in users:
                full_name = f"{user.firstname} {user.lastname}".strip()
                if full_name:
                    user_by_name[full_name] = user.id
                user_by_login[user.login] = user.id
            
            self._enum_cache = {
                'cache_time': datetime.now().timestamp(),
                'domain': self.config.redmine_domain,
                'priorities': {item['name']: item['id'] for item in priorities},
                'statuses': {item['name']: item['id'] for item in statuses},
                'trackers': {item['name']: item['id'] for item in trackers},
                'time_entry_activities': {item['name']: item['id'] for item in time_entry_activities},
                'users_by_name': user_by_name,
                'users_by_login': user_by_login
            }
            
            # 儲存到檔案
            with open(self._cache_file, 'w', encoding='utf-8') as f:
                json.dump(self._enum_cache, f, ensure_ascii=False, indent=2)
                
        except Exception as e:
            # 快取刷新失敗,使用空快取
            self._enum_cache = {
                'cache_time': 0, 
                'domain': self.config.redmine_domain,
                'priorities': {}, 
                'statuses': {}, 
                'trackers': {},
                'time_entry_activities': {},
                'users_by_name': {},
                'users_by_login': {}
            }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a manual refresh operation but doesn't disclose important traits: whether this requires special permissions, how long the refresh takes, whether it affects system performance, what happens to ongoing operations during refresh, or if there are rate limits. The mention of 'manual' implies user-initiated rather than automatic, but this is insufficient for a mutation tool with zero annotation coverage.

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

Conciseness4/5

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

The description is extremely concise with just two lines in Chinese. The first line states the purpose clearly, and the second line indicates there's a return message. There's no wasted text or redundancy. However, the structure could be slightly improved by front-loading more critical information about when and why to use this tool.

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?

For a cache refresh tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'enumeration values' specifically refers to in this context, what 'user cache' contains, what the refresh result message format might be, whether the operation is idempotent, or what side effects might occur. Given this is a mutation operation (refreshing implies changing cache state) with zero structured safety information, the description should provide more behavioral context.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description appropriately doesn't waste space discussing non-existent parameters. This meets the baseline expectation for a zero-parameter tool where the schema handles all parameter documentation.

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

Purpose3/5

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

The description states the tool '手動刷新列舉值和用戶快取' (manually refresh enumeration values and user cache), which provides a specific verb ('refresh') and resources ('enumeration values and user cache'). However, it doesn't distinguish this from potential siblings - while no direct cache-related siblings exist in the list, the purpose could overlap with other data-fetching tools like 'get_user' or 'list_users' that might involve cached data. The description is clear but lacks sibling differentiation.

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 prerequisites (like when cache becomes stale), timing considerations, or what happens if the refresh fails. With multiple data retrieval tools in the sibling list (get_user, list_users, get_issue, etc.), there's no indication of when manual cache refresh is needed versus simply fetching fresh data through those tools.

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

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