create_content_site
Create a new content site in your account by providing a name to establish your online presence and manage digital content.
Instructions
Create a new content site in the current account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Content site name |
Implementation Reference
- src/index.ts:751-775 (handler)The handler function for the 'create_content_site' tool. It sends a POST request to the Headlesshost API endpoint '/tools/content-sites' with the site name and optional sampleDataId, then returns the formatted API response or error.async ({ name, sampleDataId }) => { try { const payload = { name, sampleDataId }; const response: AxiosResponse<ApiResponse> = await apiClient.post("/tools/content-sites", payload); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } }
- src/index.ts:746-749 (schema)Input schema for the 'create_content_site' tool using Zod validation: required 'name' string and optional 'sampleDataId' string.inputSchema: { name: z.string().describe("Content site name"), sampleDataId: z.string().optional().describe("Optional sample data ID to initialize the site. The sample data list can be found in the ref data."), },
- src/index.ts:741-776 (registration)Registration of the 'create_content_site' tool using McpServer.registerTool, including title, description, input schema, and inline handler function.server.registerTool( "create_content_site", { title: "Create Content Site", description: "Create a new content site in the current account", inputSchema: { name: z.string().describe("Content site name"), sampleDataId: z.string().optional().describe("Optional sample data ID to initialize the site. The sample data list can be found in the ref data."), }, }, async ({ name, sampleDataId }) => { try { const payload = { name, sampleDataId }; const response: AxiosResponse<ApiResponse> = await apiClient.post("/tools/content-sites", payload); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: handleApiError(error), }, ], isError: true, }; } } );
- src/index.ts:87-95 (schema)TypeScript interface defining the structure of a ContentSite entity, used in API responses.interface ContentSite { id: string; name: string; description?: string; accountId: string; isActive: boolean; createdAt: string; updatedAt: string; }
- src/index.ts:158-166 (helper)Helper function used by the tool handler to format and return API error messages.function handleApiError(error: any): string { if (error.response) { return `API Error ${error.response.status}: ${error.response.data?.message || error.response.statusText}`; } else if (error.request) { return "Network Error: Unable to reach API server"; } else { return `Error: ${error.message}`; } }