ZenUml/diagramly-mcp-serverless
3.2
If you are the rightful owner of diagramly-mcp-serverless and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Diagramly MCP Serverless is a serverless MCP server built on Cloudflare Workers using TypeScript, designed to support the Streamable HTTP transport protocol.
Tools
mermaid-to-image
Converts Mermaid diagrams to images using the Kroki service.
Diagramly MCP Serverless
A Model Context Protocol (MCP) server built on Cloudflare Workers with TypeScript, supporting Streamable HTTP transport protocol.
Features
- š Serverless architecture on Cloudflare Workers
- š” Latest MCP Streamable HTTP transport protocol support
- š ļø Extensible tools framework
- š Extensible prompts framework
- š§ TypeScript type safety
- š CORS support
- š” Simple project structure, easy to extend
Project Structure
diagramly-mcp-serverless/
āāā src/
ā āāā index.ts # Main Worker entry point
ā āāā tools/
ā ā āāā index.ts # Tools registry and manager
ā ā āāā mermaid-to-image.ts # Mermaid diagram to image tool
ā āāā prompts/
ā āāā index.ts # Prompts registry and manager
ā āāā mermaid-flowchart.ts # Mermaid flowchart prompt
āāā package.json # Project dependencies
āāā tsconfig.json # TypeScript configuration
āāā wrangler.jsonc # Cloudflare Worker configuration
āāā README.md # Project documentation
Quick Start
1. Local Development
npx wrangler dev
This will start the local development server, typically at http://localhost:8787
2. Deploy to Cloudflare
npx wrangler deploy
4. Type Check
npm run type-check
API Endpoints
POST /mcp
- MCP protocol communication endpointGET /health
- Health check endpointOPTIONS /*
- CORS preflight request handling
Built-in Features
Tools
Currently includes:
- mermaid-to-image: Convert Mermaid diagrams to images
- Parameters:
diagramCode
(string),imageType
(optional: "png" | "svg") - Function: Converts Mermaid diagram code to PNG or SVG images using Kroki service
- Parameters:
Prompts
Currently includes:
- mermaid-flowchart: Convert content to Mermaid flowchart
- Parameters:
content
(string) - Function: Generates prompts to convert user content into Mermaid flowchart diagrams
- Parameters:
Extension Guide
Adding New Tools
- Create a new tool file in
src/tools/
- Define your tool following the
ToolDefinition
interface - Add it to the
toolRegistry
insrc/tools/index.ts
Example:
export const myNewTool: ToolDefinition = {
name: "my-new-tool",
description: "Description of what this tool does",
inputSchema: {
param1: z.string(),
param2: z.number().optional()
},
handler: async ({ param1, param2 }) => {
// Tool implementation logic
return {
content: [{
type: "text",
text: "Tool result"
}]
};
}
};
Adding New Prompts
- Create a new prompt file in
src/prompts/
- Define your prompt following the
PromptDefinition
interface - Add it to the
promptRegistry
insrc/prompts/index.ts
Example:
export const myNewPrompt: PromptDefinition = {
name: "my-new-prompt",
config: {
title: "My New Prompt",
description: "Description of what this prompt does",
argsSchema: { content: z.string() }
},
handler: ({ content }) => ({
messages: [{
role: "user",
content: {
type: "text",
text: `Your prompt template here: ${content}`
}
}]
})
};
Dependencies
- @modelcontextprotocol/sdk: MCP framework core
- agents: MCP agent library
- hono: Web framework for Cloudflare Workers
- zod: Data validation library
- pako: Compression library for Mermaid diagrams
License
MIT License