import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { client } from '../client.js';
export function registerBrandsTools(server: McpServer): void {
server.tool(
'create_brand',
'Create a brand profile with AI guidelines for design generation. Brands help ensure consistent branding across all postcards.',
{
name: z.string().min(1).max(100).describe('Brand name'),
goalType: z.string().min(1).describe('Goal type (e.g., seller_leads, buyer_leads, referrals)'),
goalLabel: z.string().min(1).describe('Human-readable goal label (e.g., "Get Seller Leads")'),
brandDescription: z.string().max(2000).optional().describe('Description of the brand identity'),
brandRules: z.string().max(2000).optional().describe('Rules for AI to follow when designing'),
brandVoice: z.string().max(2000).optional().describe('Brand voice and tone guidelines'),
goalRules: z.string().max(2000).optional().describe('Goal-specific design rules'),
logoUrl: z.string().url().optional().describe('URL to brand logo'),
logoDescription: z.string().max(500).optional().describe('Description of the logo for AI'),
logoRules: z.string().max(1000).optional().describe('Rules for logo usage'),
alwaysIncludeLogo: z.boolean().default(false).describe('Always include logo in designs'),
headshotUrl: z.string().url().optional().describe('URL to agent/owner headshot'),
headshotDescription: z.string().max(500).optional().describe('Description of the headshot for AI'),
alwaysIncludeHeadshot: z.boolean().default(false).describe('Always include headshot in designs'),
},
async (params) => {
try {
const brand = await client.post('/brands', params);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(brand, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'list_brands',
'Get all brand profiles for your organization.',
{},
async () => {
try {
const result = await client.get('/brands');
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(result, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'get_brand',
'Get detailed information about a specific brand.',
{
brandId: z.string().describe('Brand ID (e.g., brand_abc123)'),
},
async (params) => {
try {
const brand = await client.get(`/brands/${params.brandId}`);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(brand, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'update_brand',
'Update brand profile information. Only provided fields will be updated.',
{
brandId: z.string().describe('Brand ID to update'),
name: z.string().min(1).max(100).optional().describe('Brand name'),
goalType: z.string().min(1).optional().describe('Goal type'),
goalLabel: z.string().min(1).optional().describe('Goal label'),
brandDescription: z.string().max(2000).optional().describe('Brand description'),
brandRules: z.string().max(2000).optional().describe('Brand rules'),
brandVoice: z.string().max(2000).optional().describe('Brand voice'),
goalRules: z.string().max(2000).optional().describe('Goal rules'),
logoUrl: z.string().url().optional().describe('Logo URL'),
logoDescription: z.string().max(500).optional().describe('Logo description'),
logoRules: z.string().max(1000).optional().describe('Logo rules'),
alwaysIncludeLogo: z.boolean().optional().describe('Always include logo'),
headshotUrl: z.string().url().optional().describe('Headshot URL'),
headshotDescription: z.string().max(500).optional().describe('Headshot description'),
alwaysIncludeHeadshot: z.boolean().optional().describe('Always include headshot'),
},
async (params) => {
try {
const { brandId, ...updateData } = params;
const brand = await client.patch(`/brands/${brandId}`, updateData);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(brand, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'set_default_brand',
'Set a brand as the default brand for your organization. The default brand is used when no brand is specified.',
{
brandId: z.string().describe('Brand ID to set as default'),
},
async (params) => {
try {
const brand = await client.post(`/brands/${params.brandId}/default`);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(brand, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
}