-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add search issues tools #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||||||||||||||||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||||||||||||||||||||||
import { z } from "zod"; | ||||||||||||||||||||||
|
||||||||||||||||||||||
import { makePlaneRequest } from "../common/request-helper.js"; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export const registerSearchIssueTools = (server: McpServer): void => { | ||||||||||||||||||||||
server.tool( | ||||||||||||||||||||||
"search_issues", | ||||||||||||||||||||||
"Use this to search issues by text query. This requests project_id as uuid parameter. If you have a readable identifier for project, you can use the get_projects tool to get the project_id from it", | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
limit: z.number().describe("The number of issues to return").optional(), | ||||||||||||||||||||||
project_id: z.string().describe("The uuid identifier of the project to search issues for").optional(), | ||||||||||||||||||||||
search: z.string().describe("The search query"), | ||||||||||||||||||||||
workspace_search: z.boolean().describe("Whether to search across all projects in the workspace").optional(), | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
async ({ limit, project_id, search, workspace_search }) => { | ||||||||||||||||||||||
// send the params if not null as query string | ||||||||||||||||||||||
const queryParams = new URLSearchParams(); | ||||||||||||||||||||||
if (limit) queryParams.set("limit", limit.toString()); | ||||||||||||||||||||||
if (project_id) queryParams.set("project_id", project_id); | ||||||||||||||||||||||
if (workspace_search) queryParams.set("workspace_search", workspace_search.toString()); | ||||||||||||||||||||||
if (search) queryParams.set("search", search); | ||||||||||||||||||||||
|
||||||||||||||||||||||
const response = await makePlaneRequest( | ||||||||||||||||||||||
"GET", | ||||||||||||||||||||||
`workspaces/${process.env.PLANE_WORKSPACE_SLUG}/issues/search/?${queryParams.toString()}` | ||||||||||||||||||||||
); | ||||||||||||||||||||||
Comment on lines
+24
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard missing workspace slug and URL-encode it. Without PLANE_WORKSPACE_SLUG this hits workspaces/undefined/…, yielding confusing failures. Also encode the slug for safety. - const response = await makePlaneRequest(
- "GET",
- `workspaces/${process.env.PLANE_WORKSPACE_SLUG}/issues/search/?${queryParams.toString()}`
- );
+ const slug = process.env.PLANE_WORKSPACE_SLUG;
+ if (!slug) {
+ throw new Error("Environment variable PLANE_WORKSPACE_SLUG is required for search_issues.");
+ }
+ const path = `workspaces/${encodeURIComponent(slug)}/issues/search/?${queryParams.toString()}`;
+ const response = await makePlaneRequest("GET", path); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||
return { | ||||||||||||||||||||||
content: [ | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
type: "text", | ||||||||||||||||||||||
text: JSON.stringify(response, null, 2), | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
], | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
} | ||||||||||||||||||||||
); | ||||||||||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Don’t gate on truthiness; include false/0 and avoid dropping valid values.
Using truthy checks drops limit=0 and workspace_search=false. Prefer explicit undefined checks and always send the required search param.
📝 Committable suggestion
🤖 Prompt for AI Agents