UNPKG

@boldsign/mcp

Version:

Model Context Protocol (MCP) server for BoldSign API

35 lines (34 loc) 1.42 kB
import { UserApi } 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 ListUsersSchema = z.object({ pageSize: z.number().int().min(1).max(100), page: z.number().int().min(1).default(1), search: commonSchema.OptionalStringSchema.describe('Optional. A string used to filter the user list. The API will return contacts whose details contain this search term.'), }); export const listUsersToolDefinition = { method: ToolNames.ListUsers.toString(), name: 'List users', description: 'Retrieves a paginated list of BoldSign users, with optional filtering by a search term.', inputSchema: ListUsersSchema, async handler(args) { return await listUsersHandler(args); }, }; async function listUsersHandler(payload) { try { const userApi = new UserApi(); userApi.basePath = configuration.getBasePath(); userApi.setApiKey(configuration.getApiKey()); const userRecords = await userApi.listUsers(payload.page, payload.pageSize ?? undefined, payload.search ?? undefined); return handleMcpResponse({ data: userRecords, }); } catch (error) { return handleMcpError(error); } }