We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/daveosterjr/postcardai-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { client } from '../client.js';
export function registerDesignsTools(server: McpServer): void {
server.tool(
'create_design',
'Create a new postcard design from a text prompt using AI. By default, image generation starts immediately.',
{
name: z.string().min(1).max(200).optional().describe('Design name (auto-generated if not provided)'),
prompt: z
.string()
.min(10)
.max(5000)
.describe('Design prompt describing what you want the postcard to look like'),
size: z.enum(['4x6', '6x9', '6x11']).default('6x9').describe('Postcard size'),
orientation: z.enum(['landscape', 'portrait']).default('landscape').describe('Postcard orientation'),
brandId: z.string().optional().describe('Brand ID to apply brand guidelines'),
generateImmediately: z
.boolean()
.default(true)
.describe('Start generation immediately (true) or create as draft (false)'),
},
async (params) => {
try {
const design = await client.post('/designs', params);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(design, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'list_designs',
'Get a paginated list of designs with optional filters.',
{
limit: z.number().int().min(1).max(100).default(20).describe('Number of results per page'),
offset: z.number().int().min(0).default(0).describe('Pagination offset'),
status: z
.enum(['draft', 'generating', 'active', 'completed', 'archived'])
.optional()
.describe('Filter by status'),
publishedOnly: z.boolean().optional().describe('Only return published designs'),
search: z.string().optional().describe('Search by name'),
},
async (params) => {
try {
const result = await client.get('/designs', {
limit: params.limit,
offset: params.offset,
status: params.status,
publishedOnly: params.publishedOnly,
search: params.search,
});
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_design',
'Get detailed information about a specific design including all iterations.',
{
designId: z.string().describe('Design ID (e.g., design_abc123)'),
},
async (params) => {
try {
const design = await client.get(`/designs/${params.designId}`);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(design, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'iterate_design',
'Generate a new iteration of an existing design. Optionally provide a refinement prompt to guide the AI.',
{
designId: z.string().describe('Design ID to iterate on'),
prompt: z.string().max(5000).optional().describe('Optional refinement prompt to guide the new iteration'),
},
async (params) => {
try {
const { designId, ...body } = params;
const result = await client.post(`/designs/${designId}/iterate`, body);
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(
'publish_design',
'Publish a specific iteration as the active version of the design, making it available for use in mailings.',
{
designId: z.string().describe('Design ID'),
iterationNumber: z.number().int().min(1).describe('Iteration number to publish'),
},
async (params) => {
try {
const { designId, ...body } = params;
const design = await client.post(`/designs/${designId}/publish`, body);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(design, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text' as const,
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
isError: true,
};
}
}
);
server.tool(
'delete_design',
'Archive a design. Archived designs are not permanently deleted and can be restored.',
{
designId: z.string().describe('Design ID to delete'),
},
async (params) => {
try {
const result = await client.delete(`/designs/${params.designId}`);
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,
};
}
}
);
}