This is an MCP (Model Context Protocol) server template for MCPize hosting platform.
├── src/
│ ├── index.ts # Main server entry point
│ └── tools.ts # Pure tool functions (testable)
├── tests/
│ └── tools.test.ts # Tool unit tests
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── mcpize.yaml # MCPize deployment manifest
└── Dockerfile # Container build instructions
npm install # Install dependencies
npm run dev # Run in development mode with hot reload
npm test # Run tests with vitest
npm run build # Compile TypeScript to JavaScript
npm start # Run compiled serverThis server uses @modelcontextprotocol/sdk with Streamable HTTP transport.
server.registerTool(
"tool-name",
{
title: "Human-readable title",
description: "What this tool does",
inputSchema: {
param: z.string().describe("Parameter description"),
},
outputSchema: {
result: z.string(),
},
},
async ({ param }) => {
const output = { result: "computed value" };
return {
content: [{ type: "text", text: JSON.stringify(output) }],
structuredContent: output,
};
}
);Resources provide data that fills the context window:
server.registerResource(
"resource://data",
{
name: "Data Resource",
description: "Provides static or dynamic data",
mimeType: "application/json",
},
async () => ({
contents: [{ uri: "resource://data", text: JSON.stringify(data) }],
})
);server.registerPrompt(
"prompt-name",
{ description: "Prompt description" },
async () => ({
messages: [{ role: "user", content: { type: "text", text: "..." } }],
})
);The mcpize.yaml file controls deployment:
runtime: Server runtime (typescript, python, php)entry: Main source filebuild.install: Install commandbuild.command: Build commandstartCommand.type: Transport type (http)configSchema.source: Where to extract config schema from
PORT: Server port (default: 8080, set by MCPize)- Add custom env vars in MCPize dashboard
Use MCP Inspector to test your server:
npx @anthropic-ai/mcp-inspectorConnect to http://localhost:8080/mcp to test tools and resources.
Deploy using MCPize CLI:
mcpize deploy- Tools vs Resources: Use tools for actions, resources for data
- Error Handling: Always handle errors gracefully in tool handlers
- Structured Output: Return both
contentandstructuredContent - Descriptions: Write clear descriptions for all tools and parameters
- Validation: Use Zod schemas for input validation
- Environment Variables: Use
process.envfor configuration, never hardcode secrets