PDF Utilities MCP

PDF Utilities MCP

Enables AI assistants to read, create, merge, split, and edit PDF files through natural language commands in GitHub Copilot Chat.

Category
访问服务器

README

PDF Utilities MCP

A VS Code extension that provides comprehensive PDF manipulation tools for GitHub Copilot Chat via Model Context Protocol (MCP).

Overview

This project combines an MCP server with a VS Code extension to enable AI assistants like GitHub Copilot to work with PDF files through natural language commands. Users can read, create, merge, split, and edit PDFs directly from their chat interface.

Architecture

pdf-utilities-mcp/
├── src/                   # MCP Server implementation
│   ├── index.ts          # Server entry point and tool registration
│   └── pdf-tools.ts      # PDF manipulation utilities
├── extension/            # VS Code Extension
│   ├── src/
│   │   ├── extension.ts # Extension activation and MCP integration
│   │   └── types.ts     # TypeScript type definitions
│   ├── resources/
│   │   └── instructions/ # Copilot Chat instruction files
│   └── mcp-server/      # Built MCP server (copied from ../dist)
└── dist/                # Compiled MCP server output

Features

  • 📖 Read PDFs: Extract text content with optional page range selection
  • 📊 Get Info: Retrieve metadata (pages, title, author, size, etc.)
  • ✍️ Create PDFs: Generate new PDFs from text with formatting options
  • 🔗 Merge: Combine multiple PDF files into one
  • ✂️ Split: Extract specific pages or ranges
  • 📝 Update Metadata: Modify title, author, subject, keywords
  • 📄 Extract Pages: Save individual pages as separate files

Installation

For Users

Install from VS Code Marketplace:

  1. Open VS Code
  2. Search for "PDF Utilities" in Extensions
  3. Click Install

For Developers

# Clone the repository
git clone https://github.com/GleidsonFerSanP/pdf-utilities-mcp.git
cd pdf-utilities-mcp

# Install MCP server dependencies
npm install

# Build MCP server
npm run build

# Install extension dependencies
cd extension
npm install

# Build extension
npm run compile

# Copy MCP server to extension
cd ..
npm run copy-to-extension

Development

Project Structure

MCP Server ( src/ ):

  • Uses @modelcontextprotocol/sdk for standardized tool interface
  • Implements 7 PDF tools using pdf-lib and pdf-parse
  • Runs as Node.js process via stdio transport

VS Code Extension ( extension/ ):

  • Registers MCP server with VS Code's lm.registerMcpServerDefinitionProvider
  • Provides commands for configuration and server management
  • Includes chat instructions for optimal Copilot integration

Building

# Build MCP server
npm run build

# Build extension
cd extension
npm run compile

# Copy server to extension folder
cd ..
npm run copy-to-extension

Testing

# Test MCP server directly
node dist/index.js

# Package extension for testing
cd extension
npm run package  # Creates .vsix file

# Install .vsix in VS Code for testing
# Extensions > ... > Install from VSIX

Development Workflow

  1. Make changes to MCP server in src/
  2. Run npm run build to compile
  3. Run npm run copy-to-extension to update extension
  4. Reload VS Code window to test changes
  5. Check logs in Output panel > "PDF Utilities"

Publishing

Prerequisites

  1. Create VS Code Publisher account at https://marketplace.visualstudio.com/
  2. Generate Personal Access Token (PAT)
  3. Update extension/.env with your PAT

Publish Steps

# Build everything
npm run build
cd extension
npm run compile
cd ..
npm run copy-to-extension

# Package extension
cd extension
npm run package

# Verify the .vsix file works
# Install it manually in VS Code and test

# Publish to marketplace
npm run publish

Version Management

Update version in both:

  • package.json (root)
  • extension/package.json

Follow semantic versioning: MAJOR. MINOR. PATCH

Configuration

Extension Settings

  • pdfUtilities.autoStart: Auto-start MCP server (default: true)
  • pdfUtilities.logLevel: Logging verbosity (default: info)
  • pdfUtilities.maxPdfSize: Maximum file size in MB (default: 50)

MCP Server Configuration

The MCP server is configured via the extension and doesn't require separate configuration.

API Documentation

Tool: read_pdf

Extract text from PDF file.

Parameters:

  • filePath (string, required): Absolute path to PDF
  • pageRange (string, optional): Pages to extract (e.g., "1-5", "1, 3, 5-10")

Returns:

{
  text: string;
  pages: number;
  info: PDFInfo;
}

Tool: get_pdf_info

Get PDF metadata and information.

Parameters:

  • filePath (string, required): Absolute path to PDF

Returns:

{
  pages: number;
  title?: string;
  author?: string;
  subject?: string;
  creator?: string;
  producer?: string;
  creationDate?: Date;
  modificationDate?: Date;
  fileSize: number;
  filePath: string;
}

Tool: create_pdf

Create new PDF from text content.

Parameters:

  • content (string, required): Text content
  • outputPath (string, required): Save location
  • options (object, optional): Formatting options
    • title, author, subject (string): Metadata
    • fontSize (number): Text size (default: 12)
    • pageSize (string): Page size (default: "A4")

Returns:

{
  success: boolean;
  path: string;
  pages: number;
}

Tool: merge_pdfs

Combine multiple PDFs.

Parameters:

  • filePaths (string[], required): PDFs to merge
  • outputPath (string, required): Output location

Returns:

{
  success: boolean;
  path: string;
  pages: number;
}

Tool: split_pdf

Extract pages to new PDF.

Parameters:

  • filePath (string, required): Source PDF
  • pageRange (string, required): Pages to extract
  • outputPath (string, required): Output location

Returns:

{
  success: boolean;
  path: string;
  pages: number;
}

Tool: update_pdf_metadata

Modify PDF metadata.

Parameters:

  • filePath (string, required): PDF to update
  • metadata (object, required): Fields to update
    • title, author, subject, keywords (string)
  • outputPath (string, optional): Save location (defaults to overwrite)

Returns:

{
  success: boolean;
  path: string;
}

Tool: extract_pages

Extract pages to separate files.

Parameters:

  • filePath (string, required): Source PDF
  • pages (number[], required): Page numbers to extract
  • outputDir (string, required): Output directory
  • prefix (string, optional): Filename prefix (default: "page")

Returns:

{
  success: boolean;
  files: string[];
}

Troubleshooting

MCP Server Not Starting

Check Output panel:

View > Output > Select "PDF Utilities"

Look for initialization messages. If server fails:

  1. Verify mcp-server/index.js exists in extension folder
  2. Run rebuild: npm run build && npm run copy-to-extension
  3. Reload VS Code

Tools Not Available in Copilot

  1. Ensure extension is activated (check Extensions panel)
  2. Verify MCP API is available (requires VS Code 1.85+)
  3. Check that Copilot Chat is enabled
  4. Restart Copilot: Command Palette > "GitHub Copilot: Restart Language Server"

Build Errors

Common issues:

  • TypeScript errors: Run npm install in both root and extension folders
  • Missing dependencies: npm install in correct directory
  • Path issues: Use npm run copy-to-extension to sync files

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Please follow existing code style and conventions.

License

MIT License - see LICENSE file for details.

Support

Credits


Note: This project requires GitHub Copilot Chat and VS Code 1.85+ with MCP support.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选