JSPM

website-to-markdown-mcp

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q33104F
  • License MIT

MCP server for fetching websites and converting to markdown

Package Exports

  • website-to-markdown-mcp
  • website-to-markdown-mcp/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (website-to-markdown-mcp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

🌐 Website to Markdown MCP Server

A powerful Model Context Protocol (MCP) server designed for fetching website content and converting it to Markdown format, making it easier for AI to understand and process website information.

✨ Key Features

🌟 Core Functions πŸ“Š OpenAPI Support βš™οΈ Flexible Configuration 🎯 Smart Extraction
Website to Markdown OpenAPI 3.x/Swagger 2.0 Multiple config methods Smart content detection
Auto cleanup elements Professional validation Environment variables Main content area detection
Batch configuration Structured API parsing Real-time config updates Multi-format support

πŸš€ Quick Start

πŸ“¦ Installation

Install the package globally via npm:

npm install -g website-to-markdown-mcp

Or use it directly with npx:

npx website-to-markdown-mcp

πŸ’‘ Best Practice: Use external configuration files for easier management!

Step 1: Create Configuration File πŸ“„

Create a my-websites.json file:

{
  "websites": [
    {
      "name": "your_website",
      "url": "https://your-website.com",
      "description": "Your Project Website"
    },
    {
      "name": "api_docs",
      "url": "https://api.example.com/openapi.json",
      "description": "Your API Specification"
    }
  ]
}

Step 2: Configure MCP Server βš™οΈ

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "website-to-markdown": {
      "command": "npx",
      "args": ["-y", "website-to-markdown-mcp"],
      "disabled": false,
      "env": {
        "WEBSITES_CONFIG_PATH": "./my-websites.json"
      }
    }
  }
}

Alternative: Local Installation

If you prefer to install locally:

{
  "mcpServers": {
    "website-to-markdown": {
      "command": "node",
      "args": ["./node_modules/website-to-markdown-mcp/dist/cli.js"],
      "disabled": false,
      "env": {
        "WEBSITES_CONFIG_PATH": "./my-websites.json"
      }
    }
  }
}

Step 3: Restart and Test πŸ”„

  1. Restart Cursor
  2. Open Chat and use Agent mode
  3. Test command: Please list all configured websites

πŸŽ‰ Done! You can now start using it!


πŸ†• Complete OpenAPI/Swagger Support

πŸ”₯ New Feature Highlights

Feature OpenAPI 3.x Swagger 2.0 Description
πŸ” Auto Detection βœ… βœ… Support JSON/YAML formats
βœ… Professional Validation βœ… βœ… Using @readme/openapi-parser
πŸ“‹ Structured Parsing βœ… βœ… Endpoints, parameters, responses
πŸ”— Reference Resolution βœ… βœ… Auto handle $ref references
πŸ“Š Smart Summary βœ… βœ… Generate API overview
πŸ“ Formatted Output βœ… βœ… Readable Markdown

🌟 Pre-configured Example Websites

{
  "websites": [
    {
      "name": "petstore_openapi",
      "url": "https://petstore3.swagger.io/api/v3/openapi.json",
      "description": "πŸ• Swagger Petstore OpenAPI 3.0 Spec (Demo)"
    },
    {
      "name": "petstore_swagger",
      "url": "https://petstore.swagger.io/v2/swagger.json",
      "description": "🐱 Swagger Petstore Swagger 2.0 Spec (Demo)"
    },
    {
      "name": "github_api",
      "url": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json",
      "description": "πŸ™ GitHub REST API OpenAPI Spec"
    }
  ]
}

πŸ“¦ Installation & Setup

πŸ› οΈ System Requirements

  • Node.js 18+
  • npm or yarn
  • Cursor Editor

⚑ Quick Installation

Option 1: Global Installation (Recommended)

# Install globally
npm install -g website-to-markdown-mcp

# Verify installation
website-to-markdown-mcp --help

Option 2: Project-specific Installation

# In your project directory
npm install website-to-markdown-mcp

# Use via npx
npx website-to-markdown-mcp

Option 3: Development Setup

# Clone the repository
git clone https://github.com/your-repo/website-to-markdown-mcp.git
cd website-to-markdown-mcp

# Install dependencies
npm install

# Build project
npm run build

# Run locally
npm start

πŸŽ›οΈ Advanced Configuration Options

Configuration Priority Order

graph TD
    A[πŸ” Check Environment Variable<br/>WEBSITES_CONFIG_PATH] --> B{File exists?}
    B -->|Yes| C[βœ… Load External Config File]
    B -->|No| D[πŸ” Check Environment Variable<br/>WEBSITES_CONFIG]
    D --> E{Valid JSON?}
    E -->|Yes| F[βœ… Load Embedded Config]
    E -->|No| G[πŸ” Check config.json]
    G --> H{File exists?}
    H -->|Yes| I[βœ… Load Local Config]
    H -->|No| J[πŸ”§ Use Default Config]

🎨 Configuration Method Details

πŸ’‘ Advantages: Easy to edit, syntax highlighting, version control friendly

πŸ”§ Detailed Setup Steps
  1. Create Configuration File

    # Can be placed anywhere
    touch my-api-configs.json
  2. Edit Configuration Content

{
  "websites": [
    {
         "name": "my_docs",
      "url": "https://docs.example.com",
         "description": "πŸ“š My Documentation Website"
    }
  ]
}
  1. Set Environment Variable
{
      "env": {
       "WEBSITES_CONFIG_PATH": "./my-api-configs.json"
  }
}

πŸ“‹ Method 2: NPX with Configuration

πŸ”§ NPX Configuration Example
{
  "mcpServers": {
    "website-to-markdown": {
      "command": "npx",
      "args": ["-y", "website-to-markdown-mcp"],
      "disabled": false,
      "env": {
        "WEBSITES_CONFIG": "{\"websites\":[{\"name\":\"example\",\"url\":\"https://example.com\",\"description\":\"Example Website\"}]}"
      }
    }
  }
}

πŸ“‹ Method 3: Global Installation

πŸ”§ Global Installation Configuration

After installing globally:

{
  "mcpServers": {
    "website-to-markdown": {
      "command": "website-to-markdown-mcp",
      "disabled": false,
      "env": {
        "WEBSITES_CONFIG_PATH": "./my-websites.json"
      }
    }
  }
}

πŸ”§ Available Tools

🌐 General Tools

Tool Name Function Parameters Example
fetch_website Fetch any website url: Website URL Fetch OpenAPI spec files
list_configured_websites List configured websites None View all available websites
search_websites Search configured websites query: Search term Find relevant content

🎯 Dedicated Tools

Each configured website automatically generates corresponding dedicated tools:

  • fetch_petstore_openapi - Fetch Petstore OpenAPI 3.0 spec
  • fetch_petstore_swagger - Fetch Petstore Swagger 2.0 spec
  • fetch_github_api - Fetch GitHub API spec
  • fetch_tailwind_css - Fetch Tailwind CSS documentation

πŸ“Š Output Format Examples

🌐 General Website Content

# Website Title

**Source**: https://example.com
**Website**: example_site - Example Website

---

[Converted Markdown content...]

πŸ“‹ OpenAPI 3.x Specification File

# πŸš€ Example API (v2.1.0)

**Source**: https://api.example.com/openapi.json
**OpenAPI Version**: 3.0.3
**Validation Status**: βœ… Valid

---

## πŸ“‹ API Basic Information

- **API Name**: Example API
- **Version**: 2.1.0
- **OpenAPI Version**: 3.0.3
- **Description**: A powerful example API

## 🌐 Servers

1. **https://api.example.com**
   - 🏒 Production server
2. **https://staging-api.example.com**
   - πŸ§ͺ Testing server

## πŸ› οΈ API Endpoints

Total of **15** endpoints:

### πŸ‘₯ `/users`
- **GET**: Get user list
- **POST**: Create new user

### πŸ” `/users/{id}`
- **GET**: Get specific user
- **PUT**: Update user information
- **DELETE**: Delete user

## 🧩 Components

- **Schemas**: 8 data models
- **Parameters**: 5 reusable parameters  
- **Responses**: 12 reusable responses
- **Security Schemes**: 2 security mechanisms

🎯 Usage Examples

πŸ’» Basic Usage

Please fetch the content from https://docs.example.com and convert to markdown

πŸ” OpenAPI Specification Fetching

Please use the fetch_petstore_openapi tool to fetch Petstore OpenAPI specification

πŸ“š Documentation Website Fetching

Please fetch React official documentation content

πŸ” Search Functionality

Please search for "authentication" in all configured websites

🚨 Troubleshooting

❓ Common Issues

πŸ”§ Installation Related Issues

Q: Command not found after global installation?

  • βœ… Ensure npm global bin directory is in PATH
  • βœ… Try npm config get prefix to check npm prefix
  • βœ… Use npx website-to-markdown-mcp as alternative

Q: Permission errors during installation?

  • πŸ› οΈ Use sudo npm install -g website-to-markdown-mcp (Linux/Mac)
  • πŸ› οΈ Run PowerShell as Administrator (Windows)
  • πŸ› οΈ Configure npm to use a different directory
πŸ”§ Configuration Related Issues

Q: Configuration changes not taking effect?

  • βœ… Confirm JSON format is correct
  • βœ… Restart Cursor
  • βœ… Check environment variable names

Q: JSON format errors?

  • πŸ› οΈ Use JSON Validator
  • πŸ› οΈ Confirm using double quotes
  • πŸ› οΈ Check for extra commas
🌐 Website Fetching Issues

Q: Cannot fetch certain websites?

  • πŸ” Check if website is normally accessible
  • πŸ” Some websites have anti-crawling mechanisms
  • πŸ” Confirm network connection

Q: OpenAPI parsing failed?

  • βœ… Confirm URL points to valid JSON/YAML
  • βœ… Check specification syntax correctness
  • βœ… View detailed error messages

πŸ” Debug Mode

Detailed logs are output to stderr at startup:

# View debug messages (global installation)
website-to-markdown-mcp 2> debug.log

# View debug messages (npx)
npx website-to-markdown-mcp 2> debug.log

πŸ“ˆ Performance & Optimization

⚑ Performance Tips

  • πŸš€ Batch Fetching: Configure multiple websites at once
  • πŸ’Ύ Caching Mechanism: Repeated requests are faster
  • 🎯 Precise Selectors: Improve content extraction accuracy

πŸ›‘οΈ Security Considerations

  • πŸ”’ HTTPS websites only (recommended)
  • πŸ› οΈ Auto filter malicious scripts
  • πŸ“ Limit output content length

πŸ“¦ Dependencies

Package Version Purpose
@modelcontextprotocol/sdk ^1.0.0 MCP Core Framework
@readme/openapi-parser ^4.1.0 Professional OpenAPI Parsing
axios ^1.6.0 HTTP Request Handling
cheerio ^1.0.0 HTML Parsing Engine
turndown ^7.1.2 HTML to Markdown
yaml ^2.8.0 YAML Format Support
zod ^3.22.0 Data Validation Framework

πŸ“ Changelog

πŸŽ‰ v1.0.1 (Latest)

πŸš€ NPM Package Release

  • πŸ“¦ Published to NPM registry
  • ✨ Added Global CLI command support
  • ✨ Added NPX support for easy usage
  • πŸ”§ Improved Installation and setup process
  • πŸ“ Updated Documentation with installation methods

πŸŽ‰ v1.1.0

πŸš€ Major Feature Updates

  • ✨ Added Full OpenAPI 3.x/Swagger 2.0 support
  • ✨ Added JSON/YAML format auto-detection
  • ✨ Added Professional-grade spec validation and reference resolution
  • ✨ Added Version auto-adaptation mechanism
  • ✨ Added Structured API documentation summary
  • πŸ”§ Pre-configured Multiple OpenAPI/Swagger examples

🎯 v1.0.0 (Stable)

  • πŸŽ‰ Initial Release
  • 🌐 Basic Functions Website content fetching
  • πŸ“ Core Functions Markdown conversion
  • βš™οΈ Configuration Support Multi-website management

🀝 Contributing

πŸ’‘ How to Contribute

  1. 🍴 Fork this project
  2. 🌟 Create feature branch (git checkout -b feature/AmazingFeature)
  3. πŸ“ Commit changes (git commit -m 'Add some AmazingFeature')
  4. πŸ“€ Push to branch (git push origin feature/AmazingFeature)
  5. πŸ”„ Open Pull Request

πŸ› Issue Reporting

Report issues on the Issues page, please include:

  • πŸ” Issue Description
  • πŸ”„ Reproduction Steps
  • πŸ’» Environment Information
  • πŸ“Έ Screenshots or Logs

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


🌟 If this project helps you, please give it a Star!

πŸ’¬ Have questions or suggestions? Feel free to open an Issue!


Made by Sun ❀️ for the Developer Community