UNPKG

@boldsign/mcp

Version:

Model Context Protocol (MCP) server for BoldSign API

33 lines (32 loc) 1.61 kB
import { ContactsApi } from 'boldsign'; import { z } from 'zod'; import * as commonSchema from '../../utils/commonSchema.js'; import { configuration } from '../../utils/constants.js'; import { handleMcpError, handleMcpResponse } from '../../utils/toolsUtils.js'; import ToolNames from '../toolNames.js'; const GetContactSchema = z.object({ id: commonSchema.InputIdSchema.describe('Required. The unique identifier (ID) of the contact to retrieve. This can be obtained from the list contacts tool.'), }); export const getContactToolDefinition = { method: ToolNames.GetContact.toString(), name: 'Get contact', description: 'This tool utilizes the BoldSign API to retrieve detailed information for a specific contact within your organization. To use this tool, you need to provide the unique identifier (ID) of the contact you wish to retrieve. Contacts are primarily used to store signer details, identified by their unique email address, for use when creating and sending documents for signature within the BoldSign application.', inputSchema: GetContactSchema, async handler(args) { return await getContactHandler(args); }, }; async function getContactHandler(payload) { try { const contactsApi = new ContactsApi(); contactsApi.basePath = configuration.getBasePath(); contactsApi.setApiKey(configuration.getApiKey()); const contactsDetails = await contactsApi.getContact(payload.id); return handleMcpResponse({ data: contactsDetails, }); } catch (error) { return handleMcpError(error); } }