@smartsheet/smar-mcp
Version:
A Model Context Protocol (MCP) server for interacting with the Smartsheet API. This server provides tools for searching, retrieving, and updating Smartsheet sheets through the MCP protocol.
52 lines (51 loc) • 2.34 kB
JavaScript
import { z } from "zod";
export function getUpdateRequestTools(server, api) {
// Tool: Create Update Request
server.tool("create_update_request", "Creates an update request for a sheet", {
sheetId: z.string().describe("The ID of the sheet"),
rowIds: z.array(z.number()).optional().describe("Array of row IDs to include in the update request"),
columnIds: z.array(z.number()).optional().describe("Array of column IDs to include in the update request"),
includeAttachments: z.boolean().optional().describe("Whether to include attachments in the update request"),
includeDiscussions: z.boolean().optional().describe("Whether to include discussions in the update request"),
message: z.string().optional().describe("Message to include in the update request email"),
subject: z.string().optional().describe("Subject line for the update request email"),
ccMe: z.boolean().optional().describe("Whether to CC the sender on the update request email"),
sendTo: z.array(z.object({
email: z.string().describe("Email address of the recipient")
})).describe("Array of recipients for the update request"),
}, async ({ sheetId, rowIds, columnIds, includeAttachments, includeDiscussions, message, subject, ccMe, sendTo }) => {
try {
console.info(`Creating update request for sheet ${sheetId}`);
const result = await api.sheets.createUpdateRequest(sheetId, {
rowIds,
columnIds,
includeAttachments,
includeDiscussions,
message,
subject,
ccMe,
sendTo
});
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2)
}
]
};
}
catch (error) {
console.error("Failed to create update request", { error });
return {
content: [
{
type: "text",
text: `Failed to create update request: ${error.message}`
}
],
isError: true
};
}
});
}