/**
* Test script for BrandSnap MCP server
* Run with: npm test
*/
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { spawn } from "child_process";
async function test() {
console.log("๐งช Testing BrandSnap MCP Server\n");
// Start the server as a child process
const serverProcess = spawn("tsx", ["src/index.ts"], {
stdio: ["pipe", "pipe", "pipe"],
env: { ...process.env },
});
const transport = new StdioClientTransport({
command: "tsx",
args: ["src/index.ts"],
env: process.env,
});
const client = new Client({
name: "test-client",
version: "1.0.0",
}, {
capabilities: {},
});
try {
await client.connect(transport);
console.log("โ
Connected to server\n");
// List tools
console.log("๐ Listing tools...");
const tools = await client.listTools();
console.log("Tools available:", tools.tools.map((t) => t.name).join(", "));
const brandTool = tools.tools.find((t) => t.name === "generate_brand_identity");
if (!brandTool) {
throw new Error("generate_brand_identity tool not found");
}
console.log("โ
generate_brand_identity tool found\n");
console.log("Tool schema:", JSON.stringify(brandTool.inputSchema, null, 2));
// Test the tool (requires ANTHROPIC_API_KEY)
if (process.env.ANTHROPIC_API_KEY) {
console.log("\n๐ Testing brand identity generation...");
console.log("(This will make a real API call to Anthropic)\n");
const result = await client.callTool({
name: "generate_brand_identity",
arguments: {
business_name: "TechFlow",
industry: "Software Development",
values: "We build elegant developer tools that make coding more enjoyable. We value simplicity, efficiency, and beautiful design.",
tone: "Modern and Professional",
},
});
console.log("โ
Brand identity generated!\n");
console.log("Result preview:");
const content = result.content;
if (content[0]?.text) {
const parsed = JSON.parse(content[0].text);
console.log("- Colors:", parsed.colors?.length || 0);
console.log("- Brand Voice Tone:", parsed.brandVoice?.tone);
console.log("- Taglines:", parsed.brandVoice?.taglines?.slice(0, 2).join(", "));
console.log("- Logo Style:", parsed.logoDirection?.style);
}
}
else {
console.log("โ ๏ธ ANTHROPIC_API_KEY not set - skipping actual generation test");
console.log(" Set the environment variable to test the full functionality");
}
console.log("\nโ
All tests passed!");
}
catch (error) {
console.error("โ Test failed:", error);
process.exit(1);
}
finally {
await client.close();
serverProcess.kill();
}
}
test();