Skip to main content
Glama

search_work_items

Search for work items in PingCode projects using keywords to find bugs, requirements, or tasks. Filter results by specific projects to locate relevant project management data.

Instructions

搜索 PingCode 工作项。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes搜索关键词
project_idNo限定在某个项目中搜索(可选)

Implementation Reference

  • Schema definition for the 'search_work_items' tool, including input schema with query (required) and optional project_id.
    { name: 'search_work_items', description: '搜索 PingCode 工作项。', inputSchema: { type: 'object', properties: { query: { type: 'string', description: '搜索关键词', }, project_id: { type: 'string', description: '限定在某个项目中搜索(可选)', }, }, required: ['query'], },
  • MCP tool handler for 'search_work_items': extracts parameters, calls searchWorkItems helper, formats response with success/error handling.
    case 'search_work_items': { const { query, project_id } = args as { query: string; project_id?: string; }; const result = await searchWorkItems(query, project_id); return { content: [ { type: 'text', text: result.success ? result.data! : `错误: ${result.error}`, }, ], isError: !result.success, }; }
  • Helper function searchWorkItems that invokes the API client, handles empty results, formats search results into a markdown list.
    export async function searchWorkItems( query: string, projectId?: string ): Promise<{ success: boolean; data?: string; error?: string; }> { try { const items = await pingcodeClient.searchWorkItems(query, projectId); if (items.length === 0) { return { success: true, data: `未找到匹配 "${query}" 的工作项`, }; } const lines: string[] = [ `# 搜索结果: "${query}"`, '', `共找到 ${items.length} 项`, '', ]; items.forEach((item) => { lines.push( `- **${item.identifier}** ${item.title}`, ` - 类型: ${item.type?.display_name || item.type?.name} | 状态: ${item.state?.display_name || item.state?.name}`, '' ); }); return { success: true, data: lines.join('\n'), }; } catch (error: any) { return { success: false, error: error.message, }; } }
  • PingCodeClient method that performs the HTTP GET request to /api/pjm/work-items/search with authentication and query parameters.
    async searchWorkItems(query: string, projectId?: string): Promise<WorkItem[]> { const headers = this.getAuthHeaders(); try { const params: Record<string, any> = { q: query, page_size: 20, }; if (projectId) { params.project_id = projectId; } const response = await this.client.get('/api/pjm/work-items/search', { headers, params, }); return response.data?.values || []; } catch (error: any) { if (error.response?.status === 401) { throw new Error('登录已过期,请重新调用 login 工具登录'); } throw error; } }

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/ratatatat1/pingcode-mcp'

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