package7-mcp
v0.0.3
Published
Universal MCP server for accessing library documentation through LLM agents
Maintainers
Readme
Documentation Index MCP
Universal MCP (Model Context Protocol) server for accessing and searching library documentation. Enables LLM agents to retrieve and analyze documentation for any configured library using advanced text ranking algorithms.
Features
- Multi-Library Support: Access documentation for multiple configured libraries simultaneously
- Advanced Search: Keyword-based document retrieval with BM25 ranking algorithm for precise results
- Intelligent Document Processing: Parse and process markdown documentation with token estimation
- Semantic Chunking: Split documents into semantically meaningful chunks for better context management
- Token Management: Efficient token counting and management for LLM context windows
- Metadata Extraction: Automatic extraction of document structure and metadata (headings, code blocks, tables)
- Category-Based Weighting: Intelligent ranking based on document categories and sections
- Flexible Configuration: Support for multiple search modes and customizable keyword weighting
- Built with TypeScript: Full type safety and comprehensive test coverage
Installation
NPM
npm install -g package7-mcpSmithery
To install Documentation Index MCP Server for any client automatically via Smithery:
npx -y @smithery/cli@latest install package7-mcp --client <CLIENT_NAME>Available clients: cursor, claude, vscode, windsurf, cline, zed, etc.
Example for Cursor:
npx -y @smithery/cli@latest install package7-mcp --client cursorFrom Source
# Install dependencies
pnpm install
# Build the project
pnpm build
# Run the server
pnpm startMCP Client Integration
Documentation Index MCP can be integrated with various AI coding assistants and IDEs that support the Model Context Protocol (MCP).
Requirements
- Node.js >= v18.0.0
- pnpm >= v8.0.0
- An MCP-compatible client (Cursor, Claude Code, VS Code, Windsurf, etc.)
Go to: Settings -> Cursor Settings -> MCP -> Add new global MCP server
Add the following configuration to your ~/.cursor/mcp.json file:
{
"mcpServers": {
"docs-index": {
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}Run this command:
claude mcp add docs-index -- npx -y package7-mcpAdd this to your VS Code MCP config file. See VS Code MCP docs for more info.
"mcp": {
"servers": {
"docs-index": {
"type": "stdio",
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}Add this to your Windsurf MCP config file:
{
"mcpServers": {
"docs-index": {
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}- Open Cline
- Click the hamburger menu icon (☰) to enter the MCP Servers section
- Choose Remote Servers tab
- Click the Edit Configuration button
- Add docs-index to
mcpServers:
{
"mcpServers": {
"docs-index": {
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}Open Claude Desktop developer settings and edit your claude_desktop_config.json file:
{
"mcpServers": {
"docs-index": {
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}Add this to your Zed settings.json:
{
"context_servers": {
"docs-index": {
"source": "custom",
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}Add this to your Roo Code MCP configuration file:
{
"mcpServers": {
"docs-index": {
"command": "npx",
"args": ["-y", "package7-mcp"]
}
}
}{
"mcpServers": {
"docs-index": {
"command": "bunx",
"args": ["-y", "package7-mcp"]
}
}
}Usage
The MCP server provides the following tools:
get-library-list
Retrieve the list of available libraries and their metadata.
Parameters: None
Returns:
{
"libraries": [
{
"id": "react",
"name": "React",
"version": "18.0.0",
"description": "A JavaScript library for building user interfaces"
}
]
}get-documents
Search library documentation with keyword-based retrieval using BM25 ranking algorithm.
Parameters:
{
"libraryId": "react",
"query": "hooks state management",
"limit": 10
}Returns: Array of documents with scores and metadata:
{
"documents": [
{
"id": "doc-123",
"title": "Using the State Hook",
"content": "...",
"score": 0.95,
"metadata": {
"section": "Hooks",
"category": "Advanced"
}
}
]
}document-by-id
Get full document content by ID.
Parameters:
{
"documentId": "doc-123"
}Returns:
{
"id": "doc-123",
"title": "Using the State Hook",
"content": "Complete document content...",
"metadata": {
"tokens": 1250,
"section": "Hooks"
}
}Usage Examples
Example 1: Search for documentation
In Cursor/Claude Code:
Search for React documentation about hooks and find examples of useState usageExample 2: Get specific library information
In any MCP client:
What libraries are available and show me the latest React documentationExample 3: Analyze code patterns
In Cursor/Claude Code:
I need to understand how to manage state in React.
Search the React documentation for state management patterns.Architecture
The project follows a modular architecture:
- constants/: Configuration constants and base prompts
- document/: Document processing logic
- splitter/: Markdown parsing and document chunking utilities
- parser/: Specialized parsers for different node types
- repository/: Data access layer and document repositories
- schema/: Zod schemas for runtime type validation
- tool/: MCP tool implementations
- server.ts: Main server entry point
Core Components
- MarkdownSplitter: Intelligent markdown document splitting with semantic awareness
- BM25Calculator: Advanced ranking algorithm for search relevance
- TokenEstimator: Efficient token counting for context management
- DocumentLoader: Flexible document loading and caching
- ChunkConverter: Conversion between different document formats
Development
Setup
# Install dependencies
pnpm install
# Run in development mode (watch mode)
pnpm dev
# Type check
pnpm typecheckBuilding
pnpm buildCode Quality
# Lint code
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code with Prettier
pnpm formatTesting
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Generate coverage report
pnpm test:coverageThe project includes comprehensive test coverage for:
- Document processing and parsing
- BM25 ranking algorithm
- Token estimation
- Search functionality
- Repository operations
Project Structure
src/
├── constants/ # Configuration constants and prompts
│ ├── base-prompt.ts # Base system prompts
│ ├── category.ts # Category definitions
│ ├── keyword-weight-config.ts # Search weight configuration
│ └── search-mode.ts # Search mode definitions
├── document/ # Document processing logic
│ ├── splitter/ # Markdown splitting utilities
│ │ ├── markdown-splitter.ts # Main splitter
│ │ ├── parser/ # Node-type specific parsers
│ │ └── extractMetadata.ts # Metadata extraction
│ ├── token-estimator.ts # Token counting
│ ├── document-loader.ts # Document loading
│ ├── chunk-converter.ts # Format conversion
│ └── __test__/ # Document tests
├── repository/ # Data access layer
│ ├── docs.repository.ts # Document repository
│ └── createDocsRepository.ts # Factory function
├── schema/ # Zod schemas
│ └── get-document-schema.ts # Request schemas
├── tool/ # MCP tool implementations
│ └── tools.ts # Tool definitions
└── server.ts # Main server entry pointConfiguration
Search Modes
The server supports multiple search modes configured via constants:
- BM25: Advanced relevance ranking (default)
- Keyword: Simple keyword matching
- Semantic: Context-aware search
Category Weighting
Documents can be weighted by category for better ranking:
const categoryWeights = {
'Getting Started': 1.2,
'API': 1.0,
'Examples': 0.9
};Scripts
pnpm build- Build the project with TypeScriptpnpm dev- Development mode with watchpnpm start- Start the MCP serverpnpm test- Run all testspnpm test:watch- Run tests in watch modepnpm test:coverage- Generate coverage reportpnpm lint- Lint code with ESLintpnpm lint:fix- Fix linting issuespnpm format- Format code with Prettierpnpm typecheck- Type check without building
Docker Support
Build Docker Image
docker build -t package7-mcp .Run with Docker
docker run -d -p 3000:3000 \
--name docs-index \
package7-mcpDocker Compose Example
Create a docker-compose.yml:
version: '3.8'
services:
docs-index:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/mcp', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5sRun with Docker Compose:
docker-compose up -dContributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
Author
choesumin
