mdmcp

andrewtdiz/mdmcp

3.3

If you are the rightful owner of mdmcp 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.

The Model Context Protocol (MCP) server is a robust framework designed to efficiently serve markdown content with dynamic template support, providing a seamless integration with modern web interfaces.

Tools
3
Resources
0
Prompts
0

MDMCP - Markdown MCP

Markdown MCP is a more accurate, token efficient framework for building an MCP server

A unified monorepo containing both a Next.js frontend application and an MCP (Model Context Protocol) server for serving markdown text. This project provides a complete solution for rendering and serving markdown content with dynamic template support and a modern web interface.

šŸš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0
  • npm (comes with Node.js)
  • Git

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd modelmarkdownprotocol
    
  2. Install frontend dependencies:

    cd frontend && npm install
    
  3. Install MCP server dependencies:

    cd mcp && npm install
    
  4. Install at the project root and start development servers:

    npm install && npm run dev
    

This will start both the frontend (Next.js) and MCP server concurrently. The frontend will be available at http://localhost:3000 and the MCP server will run on its configured port.

šŸ“¦ Installation as Package

npm install mdmcp

CLI Usage

After installing globally or using npx:

# Start MCP server
mdmcp-server

# Start Next.js frontend server
mdmcp-frontend

šŸ—ļø Project Structure

mdmcp/
ā”œā”€ā”€ frontend/                    # Next.js frontend application
│   ā”œā”€ā”€ app/                    # Next.js App Router pages
│   │   ā”œā”€ā”€ layout.tsx         # Root layout component
│   │   ā”œā”€ā”€ page.tsx           # Home page
│   │   ā”œā”€ā”€ ClientRouter.tsx   # Client-side routing
│   │   └── [...slug]/         # Dynamic routing
│   ā”œā”€ā”€ src/                   # Source code
│   │   ā”œā”€ā”€ components/        # Reusable UI components
│   │   │   └── ui/           # Radix UI components
│   │   └── utils/            # Utility functions
│   ā”œā”€ā”€ styles/               # Global styles
│   ā”œā”€ā”€ package.json          # Frontend dependencies
│   ā”œā”€ā”€ next.config.js        # Next.js configuration
│   ā”œā”€ā”€ tailwind.config.js    # Tailwind CSS configuration
│   └── tsconfig.json         # TypeScript configuration
ā”œā”€ā”€ mcp/                       # MCP server implementation
│   ā”œā”€ā”€ index.ts              # Main server entry point
│   ā”œā”€ā”€ sessions.ts           # Session management
│   ā”œā”€ā”€ tools/                # MCP tools
│   │   ā”œā”€ā”€ navigate.ts       # Navigation tool
│   │   ā”œā”€ā”€ startHere.ts      # Start here tool
│   │   └── sendRequest.ts    # Request sending tool
│   ā”œā”€ā”€ utils/                # Server utilities
│   ā”œā”€ā”€ package.json          # MCP server dependencies
│   └── tsconfig.json         # TypeScript configuration
ā”œā”€ā”€ md/                        # Markdown content and conversion
│   ā”œā”€ā”€ _generated/           # Auto-generated markdown files
│   ā”œā”€ā”€ converter.ts          # Markdown ↔ TypeScript converter
│   ā”œā”€ā”€ convert-all.ts        # Batch conversion script
│   ā”œā”€ā”€ convert-single.ts     # Single file conversion
│   └── *.md                  # Source markdown files
ā”œā”€ā”€ dist/                      # Built output (generated)
ā”œā”€ā”€ package.json              # Root package configuration
ā”œā”€ā”€ tsconfig.json             # Root TypeScript configuration
└── README.md

šŸ› ļø Development

Available Scripts

ScriptDescription
npm run devStart both frontend and MCP server in development mode
npm run dev:frontendStart only the Next.js frontend
npm run dev:mcpStart only the MCP server
npm run buildBuild both services for production
npm run build:frontendBuild only the frontend
npm run build:mcpBuild only the MCP server
npm run startStart the frontend in production mode
npm run start:frontendStart the Next.js frontend
npm run start:mcpStart the MCP server
npm run cleanClean all build outputs and dependencies
npm run install:allInstall dependencies for all packages
npm run generateConvert all TypeScript files to markdown
npm run generate:singleConvert a single file
npm run watch:mdWatch markdown files for changes

Development Workflow

  1. Frontend Development:

    cd frontend
    npm run dev
    
    • Runs on http://localhost:3000
    • Hot reload enabled
    • TypeScript type checking
  2. MCP Server Development:

    cd mcp
    npm run dev
    
    • Uses tsx for TypeScript execution
    • Auto-restart on file changes
  3. Markdown Content Development:

    # Watch for markdown changes
    npm run watch:md
    
    # Generate all markdown files
    npm run generate
    

šŸ“ Markdown Support & Formatting

MDMCP supports rich markdown formatting with advanced features:

Standard Markdown

  • Headers: # H1, ## H2, ### H3, etc.
  • Emphasis: *italic*, **bold**, ***bold italic***
  • Lists: Ordered (1.) and unordered (-, *)
  • Links: [text](route_id)
  • Images: ![alt](src)
  • Code: `inline` and code blocks
  • Blockquotes: > quote
  • Tables: GitHub Flavored Markdown tables
  • Horizontal Rules: ---

Extended Features

GitHub Flavored Markdown (GFM)
  • Strikethrough: ~~deleted text~~
  • Task Lists: - [x] completed / - [ ] todo
  • Tables with alignment
  • Automatic route_id linking
  • Line breaks: Respected without requiring double spaces
MDX Support
  • React Components: Embed React components in markdown
  • JSX: Use JSX syntax within markdown
  • Imports: Import and use components
Code Syntax Highlighting

Supports syntax highlighting for:

  • JavaScript/TypeScript
  • HTML/CSS
  • JSON
  • Bash/Shell
  • Python
  • And many more languages
Template Variables

Dynamic content with template variables:

Hello {{name}}, welcome to {{project}}!

Converted to TypeScript functions:

export function template({name, project}: {name: string, project: string}): string {
  return `Hello ${name}, welcome to ${project}!`;
}

Markdown Conversion System

The project includes a sophisticated markdown ↔ TypeScript conversion system:

TypeScript to Markdown
  • Extracts template literals from TypeScript exports
  • Handles escaped backticks properly
  • Maintains formatting and structure
Markdown to TypeScript
  • Converts markdown to TypeScript template functions
  • Automatically detects template variables ({{variable}})
  • Generates type-safe functions for templated content
  • Creates constant exports for static content
Usage Examples

Convert markdown to TypeScript:

npm run generate:single -- path/to/file.md

Convert TypeScript to markdown:

npm run generate:single -- path/to/file.ts

Batch conversion:

npm run generate

šŸ­ Production

Building for Production

# Build everything
npm run build

# Or build individually
npm run build:frontend
npm run build:mcp

Production Deployment

  1. Frontend (Next.js):

    npm run start:frontend
    
  2. MCP Server:

    npm run start:mcp
    
  3. Using built binaries:

    # After npm pack and install
    mdmcp-frontend
    mdmcp-server
    

🧩 Technology Stack

Frontend Technologies

  • Next.js 15 - React framework with App Router
  • React 18 - UI library with latest features
  • TypeScript 5+ - Type safety and developer experience
  • Tailwind CSS - Utility-first CSS framework
  • Radix UI - Unstyled, accessible UI components
  • MDX - Markdown with JSX support
  • React Markdown - Markdown rendering with custom components
  • Remark GFM - GitHub Flavored Markdown support
  • Lucide React - Icon library

Backend Technologies

  • Model Context Protocol SDK - MCP server implementation
  • Express.js 5 - Web application framework
  • TypeScript - Type-safe server development
  • Zod - Runtime type validation
  • Node.js 18+ - JavaScript runtime

Development Tools

  • tsx - TypeScript execution for Node.js
  • Concurrently - Run multiple commands simultaneously
  • Chokidar - File watching for development
  • ESLint - Code linting
  • Autoprefixer - CSS vendor prefixing

šŸ”§ Configuration

Environment Variables

Create .env.local in the frontend directory:

# Add your environment variables here
NEXT_PUBLIC_API_URL=http://localhost:8080

TypeScript Configuration

The project uses a monorepo TypeScript setup with:

  • Root tsconfig.json for shared configuration
  • Frontend-specific TypeScript configuration
  • MCP server-specific TypeScript configuration

Tailwind CSS

Fully configured with:

  • Custom color scheme
  • Responsive design utilities
  • Component variants
  • Animation support

šŸ¤ Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Run tests: npm test
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

šŸ“„ License

MIT License - see LICENSE file for details

šŸ†˜ Support

  • Issues: Report bugs and request features on GitHub Issues
  • Documentation: Comprehensive docs available in the codebase
  • Community: Join discussions in GitHub Discussions

Built with ā¤ļø using Next.js, TypeScript, and the Model Context Protocol