UNPKG

@boldsign/mcp

Version:

Model Context Protocol (MCP) server for BoldSign API

35 lines (34 loc) 1.65 kB
import { TeamsApi } 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 ListTeamsSchema = z.object({ pageSize: z.number().int().min(1).max(100), page: z.number().int().min(1).default(1), searchKey: commonSchema.OptionalStringSchema.describe('Optional. A search term to filter the list of teams. The API will return teams whose details, such as name, match the provided search term.'), }); export const listTeamsToolDefinition = { method: ToolNames.ListTeams.toString(), name: 'List teams', description: 'Retrieve a paginated list of teams within your BoldSign organization. This API fetches team details such as team name, users, created date, and modified date for all listed teams, with options for filtering using a search term and navigating through pages of results.', inputSchema: ListTeamsSchema, async handler(args) { return await listTeamsHandler(args); }, }; async function listTeamsHandler(payload) { try { const teamsApi = new TeamsApi(); teamsApi.basePath = configuration.getBasePath(); teamsApi.setApiKey(configuration.getApiKey()); const teamListResponse = await teamsApi.listTeams(payload.page, payload.pageSize ?? undefined, payload.searchKey ?? undefined); return handleMcpResponse({ data: teamListResponse, }); } catch (error) { return handleMcpError(error); } }