search_projects
Locate specific projects by name using partial matching, enabling efficient project management within the Semantic Pen MCP Server’s AI-powered content creation and optimization environment.
Instructions
Search projects by name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectName | Yes | The project name to search for (partial match) |
Implementation Reference
- src/index.ts:440-496 (handler)The primary handler function that executes the search_projects tool. It fetches all projects from the '/article-queue' API endpoint, filters them by projectName using case-insensitive partial matching, groups duplicates by project_id, and returns a formatted markdown list of matching projects or an error message.private async searchProjects(projectName: string) { const result = await this.makeRequest<ProjectQueueResponse>('/article-queue'); if (result.success && result.data) { const allProjects = result.data.data.projects; const matchingProjects = allProjects.filter(project => project.project_name.toLowerCase().includes(projectName.toLowerCase()) ); if (matchingProjects.length === 0) { return { content: [ { type: "text", text: `No projects found matching "${projectName}"` } ] }; } // Group by project_id to show unique projects const uniqueProjects = matchingProjects.reduce((acc: { [key: string]: Project & { articles: string[] } }, project) => { if (!acc[project.project_id]) { acc[project.project_id] = { ...project, articles: [project.extra_data.targetArticleTopic] }; } else { acc[project.project_id].articles.push(project.extra_data.targetArticleTopic); } return acc; }, {}); const projectList = Object.values(uniqueProjects).map(project => `📁 **${project.project_name}**\n Project ID: ${project.project_id}\n Articles: ${project.articles.length}\n Latest: ${project.articles[0]}\n Created: ${new Date(project.created_at).toLocaleDateString()}` ).join('\n\n'); return { content: [ { type: "text", text: `🔍 **Projects matching "${projectName}"** (${Object.keys(uniqueProjects).length} found)\n\n${projectList}` } ] }; } else { return { content: [ { type: "text", text: `❌ Failed to search projects: ${result.error}` } ], isError: true }; } }
- src/index.ts:217-230 (registration)Registers the search_projects tool in the ListTools response, including its name, description, and input schema definition.{ name: "search_projects", description: "Search projects by name", inputSchema: { type: "object", properties: { projectName: { type: "string", description: "The project name to search for (partial match)" } }, required: ["projectName"] } },
- src/index.ts:220-229 (schema)Defines the input schema for the search_projects tool, specifying that it requires a 'projectName' string parameter.inputSchema: { type: "object", properties: { projectName: { type: "string", description: "The project name to search for (partial match)" } }, required: ["projectName"] }
- src/index.ts:302-307 (handler)Dispatcher case in the CallToolRequest handler that validates input arguments and delegates to the searchProjects method.case "search_projects": { if (!args || typeof args !== 'object' || !('projectName' in args) || typeof args.projectName !== 'string') { throw new Error("projectName is required and must be a string"); } return await this.searchProjects(args.projectName); }