UNPKG

mcp-planes-server

Version:

Plane API client and server

258 lines (257 loc) 6.72 kB
import { client } from "../shared.js"; // Project handlers export async function listProjects() { const projects = await client.getProjects(); return { content: [ { type: "text", text: JSON.stringify({ projects }, null, 2), }, ], }; } export async function getProject(input) { const project = await client.getProject(input.projectId); return { content: [ { type: "text", text: JSON.stringify({ project }, null, 2), }, ], }; } export async function createProject(input) { const project = await client.createProject(input); return { content: [ { type: "text", text: JSON.stringify({ project }, null, 2), }, ], }; } export async function updateProject(input) { const { projectId, ...data } = input; const project = await client.updateProject(projectId, data); return { content: [ { type: "text", text: JSON.stringify({ project }, null, 2), }, ], }; } export async function deleteProject(input) { await client.deleteProject(input.projectId); return { content: [ { type: "text", text: JSON.stringify({ success: true }, null, 2), }, ], }; } // Issue handlers export async function listIssues(input) { const issues = await client.getIssues(input.projectId); return { content: [ { type: "text", text: JSON.stringify({ issues }, null, 2), }, ], }; } export async function getIssue(input) { const issue = await client.getIssue(input.projectId, input.issueId); return { content: [ { type: "text", text: JSON.stringify({ issue }, null, 2), }, ], }; } export async function createIssue(input) { const { projectId, ...data } = input; const issue = await client.createIssue(projectId, data); return { content: [ { type: "text", text: JSON.stringify({ issue }, null, 2), }, ], }; } export async function updateIssue(input) { const { projectId, issueId, ...data } = input; const issue = await client.updateIssue(projectId, issueId, data); return { content: [ { type: "text", text: JSON.stringify({ issue }, null, 2), }, ], }; } export async function deleteIssue(input) { await client.deleteIssue(input.projectId, input.issueId); return { content: [ { type: "text", text: JSON.stringify({ success: true }, null, 2), }, ], }; } // Label handlers export async function listLabels(input) { const labels = await client.getLabels(input.projectId); return { content: [ { type: "text", text: JSON.stringify({ labels }, null, 2), }, ], }; } export async function createLabel(input) { const { projectId, ...data } = input; const label = await client.createLabel(projectId, data); return { content: [ { type: "text", text: JSON.stringify({ label }, null, 2), }, ], }; } export async function updateLabel(input) { const { projectId, labelId, ...data } = input; const label = await client.updateLabel(projectId, labelId, data); return { content: [ { type: "text", text: JSON.stringify({ label }, null, 2), }, ], }; } export async function deleteLabel(input) { await client.deleteLabel(input.projectId, input.labelId); return { content: [ { type: "text", text: JSON.stringify({ success: true }, null, 2), }, ], }; } // Comment handlers export async function listComments(input) { const comments = await client.getComments(input.projectId, input.issueId); return { content: [ { type: "text", text: JSON.stringify({ comments }, null, 2), }, ], }; } export async function createComment(input) { const { projectId, issueId, ...data } = input; const comment = await client.createComment(projectId, issueId, data); return { content: [ { type: "text", text: JSON.stringify({ comment }, null, 2), }, ], }; } export async function updateComment(input) { const { projectId, issueId, commentId, ...data } = input; const comment = await client.updateComment(projectId, issueId, commentId, data); return { content: [ { type: "text", text: JSON.stringify({ comment }, null, 2), }, ], }; } export async function deleteComment(input) { await client.deleteComment(input.projectId, input.issueId, input.commentId); return { content: [ { type: "text", text: JSON.stringify({ success: true }, null, 2), }, ], }; } // State handlers export async function listStates(input) { const states = await client.getStates(input.projectId); return { content: [ { type: "text", text: JSON.stringify({ states }, null, 2), }, ], }; } export async function createState(input) { const { projectId, ...data } = input; const state = await client.createState(projectId, data); return { content: [ { type: "text", text: JSON.stringify({ state }, null, 2), }, ], }; } export async function updateState(input) { const { projectId, stateId, ...data } = input; const state = await client.updateState(projectId, stateId, data); return { content: [ { type: "text", text: JSON.stringify({ state }, null, 2), }, ], }; } export async function deleteState(input) { await client.deleteState(input.projectId, input.stateId); return { content: [ { type: "text", text: JSON.stringify({ success: true }, null, 2), }, ], }; }