import { z } from "zod";
import { experimental_PaidMcpAgent as PaidMcpAgent } from "@stripe/agent-toolkit/cloudflare";
export function validateCodeComplianceTool(agent: PaidMcpAgent<Env, any, any>) {
const server = agent.server;
// @ts-ignore
server.tool(
"validate_code_compliance",
"Cross-reference project specs against applicable codes. Identify conflicts between local, state, and national requirements. Determine if professional engineer/architect stamp required.",
{
projectDescription: z.string().describe("Detailed project description with technical specifications"),
jurisdiction: z.string().describe("Municipality, county, or state jurisdiction"),
projectType: z.enum(["residential", "commercial", "industrial", "mixed-use", "accessory", "renovation", "addition"]).describe("Type of construction project"),
occupancyType: z.string().optional().describe("Specific occupancy classification (e.g., 'R-3', 'B', 'A-2')"),
constructionType: z.string().optional().describe("Construction type (e.g., 'Type V-B', 'Type II-A')"),
projectSpecs: z.object({
area: z.number().optional().describe("Building area in square feet"),
height: z.number().optional().describe("Building height in feet"),
stories: z.number().optional().describe("Number of stories"),
use: z.string().optional().describe("Intended use of the building"),
systems: z.array(z.string()).optional().describe("Building systems involved (electrical, plumbing, HVAC, etc.)")
}).optional().describe("Detailed project specifications"),
},
async ({ projectDescription, jurisdiction, projectType, occupancyType, constructionType, projectSpecs }: {
projectDescription: string;
jurisdiction: string;
projectType: string;
occupancyType?: string;
constructionType?: string;
projectSpecs?: any;
}) => {
// This would integrate with building code databases to validate compliance
// For now, return a structured response indicating the validation request
const validationParams = {
projectDescription,
jurisdiction,
projectType,
occupancyType: occupancyType || "To be determined",
constructionType: constructionType || "To be determined",
projectSpecs: projectSpecs || {}
};
return {
content: [
{
type: "text",
text: `Code Compliance Validation\n\nProject: ${validationParams.projectDescription}\nJurisdiction: ${validationParams.jurisdiction}\nProject Type: ${validationParams.projectType}\nOccupancy: ${validationParams.occupancyType}\nConstruction Type: ${validationParams.constructionType}\n\nThis tool would perform a comprehensive compliance review including:\n\n- Applicable code requirements identification\n- Conflict detection between local/state/national codes\n- Professional stamp requirements assessment\n- Permit requirement determination\n- Inspection requirement identification\n- Code violation identification\n- Compliance pathway recommendations\n- Professional consultation recommendations\n\nFor complex projects, always recommend professional engineering/architectural review.`
}
]
};
}
);
}