mrhillsman-talks/afrotech-connect-and-control-pdfmcpdemo
If you are the rightful owner of afrotech-connect-and-control-pdfmcpdemo and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Model Context Protocol (MCP) server is a sophisticated backend system designed to manage and manipulate PDF documents using AI-powered features. It integrates with various components to provide document browsing, summarization, and format conversion capabilities.
PDF Document Management System with MCP
A sophisticated document management platform built with Next.js, Model Context Protocol (MCP), and AI-powered features for PDF document browsing, summarization, and format conversion.
🎯 Features
- 📚 Document List View - Browse PDF documents with rich metadata (title, authors, tags, page count)
- 👁️ Quick Preview - Click to view document abstracts in a modal
- 📖 Full Document Viewer - View complete PDFs with zoom and navigation controls
- 🤖 AI-Powered Summaries - Generate brief, detailed, or comprehensive summaries using Claude AI
- 📝 Adaptive Elicitation - Smart preference gathering for large documents (>50 pages)
- 🔄 Format Conversion - Convert PDFs to EPUB or Markdown formats
- 💾 Local Storage - Only metadata stored locally; full PDFs fetched on-demand
- 🎨 Modern UI - Beautiful interface built with Tailwind CSS and shadcn/ui
🏗️ Architecture
This system implements the Model Context Protocol (MCP) architecture:
┌─────────────────────────────────────┐
│ Next.js UI (MCP Host) │
│ • Document list & viewer │
│ • User interactions │
└─────────────┬───────────────────────┘
│ instantiates
↓
┌─────────────────────────────────────┐
│ MCP Client (FastMCP) │
│ • Roots: Reformatted docs dir │
│ • Sampling: LLM API access │
│ • Elicitation: User prompts │
└─────────────┬───────────────────────┘
│ MCP Protocol
↓
┌─────────────────────────────────────┐
│ MCP Server (Python/FastMCP) │
│ • Document tools │
│ • Summary generation │
│ • Format conversion │
└─────────────┬───────────────────────┘
│ API calls
↓
┌─────────────────────────────────────┐
│ PDF Document Provider Service │
│ • Full PDF storage │
│ • Document metadata API │
└─────────────────────────────────────┘
Key Components
-
Next.js UI (MCP Host)
- Frontend application
- Instantiates MCP client
- Manages user interactions
-
MCP Client
- Roots: Exposes reformatted documents directory
- Sampling: Provides LLM access for summaries
- Elicitation: Handles adaptive user prompts
-
MCP Server
- Connects to PDF provider service
- Exposes document manipulation tools
- Orchestrates AI operations
-
PDF Provider Service
- External service (not included)
- Stores full PDF documents
- Provides metadata and retrieval APIs
🚀 Quick Start
Prerequisites
- Node.js 18+
- Python 3.10+
- pnpm (recommended) or npm
- Anthropic API key
Installation
-
Clone the repository
git clone <repository-url> cd afrotech-cac-dv -
Install dependencies
# Frontend pnpm install # MCP Server cd server pip install -r requirements.txt cd .. -
Configure environment variables
cp .env.example .env.localEdit
.env.local:ANTHROPIC_API_KEY=sk-ant-... PDF_PROVIDER_API_URL=https://provider.example.com PDF_PROVIDER_API_KEY=provider_key_... MCP_SERVER_URL=http://localhost:3001 REFORMATTED_DOCS_PATH=/path/to/reformatted-docs -
Start the development servers
Terminal 1 - Next.js UI:
pnpm devTerminal 2 - MCP Server:
cd server python main.py -
Open the application
http://localhost:3000
📖 Usage
Browsing Documents
- Navigate to the home page to see all available documents
- Each card shows title, authors, tags, and page count
- Click any document to open the preview modal
Viewing Previews
- Preview modal displays the document abstract
- Click "View More" to load the full document
Generating Summaries
For small documents (<50 pages):
- Click "Create Summary"
- Summary automatically generated (brief, ~500 words)
- Summary displayed instantly
For large documents (>50 pages):
- Click "Create Summary"
- Elicitation dialog appears with options:
- Summary Type: Brief / Detailed / Comprehensive
- Max Words: 300-5000 (slider)
- Include Citations: Yes/No
- Choose action:
- Accept: Use your preferences
- Use Defaults: Skip customization
- Cancel: Abort operation
- Summary generated according to preferences
- Summary displayed with metadata
Converting Formats
- View a full document
- Click "Convert to EPUB" or "Convert to Markdown"
- Conversion process starts
- Converted file saved to
reformatted-docs/directory - Download link provided
🧪 Testing
Run Tests
# All tests (unit + integration + E2E)
pnpm test
# Watch mode for development
pnpm test:watch
# Coverage report
pnpm test:coverage
# Interactive UI mode
pnpm test:ui
Test Statistics
✓ Test Files: 11 passed
✓ Tests: 250 passed | 3 skipped
✓ Coverage: ~75%
✓ Duration: ~8 seconds
Test Suites
- Unit Tests (41): MCP client modules (sampling, elicitation)
- Component Tests (185): All UI components with React Testing Library
- Integration Tests (14): All 6 API routes and MCP communication
- E2E Tests (10): Complete user workflows and journeys
Mock Mode
The application includes a comprehensive mock mode for development without requiring the MCP server:
// Enabled by default in development
const client = createMCPClient(); // useMock: true
See for detailed testing documentation.
📚 Documentation
Core Documentation
- - Complete system architecture and design
- - API endpoints and MCP tools reference
- - End-user instructions and workflows
Development Guides
- - Developer setup and contributing guide
- - Testing strategy and guidelines
- - Production deployment guide
MCP Documentation
- - MCP client implementation details
- - MCP server tools and configuration
- - Quick MCP reference
Project Planning
- - Development roadmap
- - Current progress (96%)
- - Step-by-step plan for remaining 4%
🛠️ Technology Stack
Frontend
- Framework: Next.js 15+ (App Router)
- Language: TypeScript 5+
- Styling: Tailwind CSS v4
- Components: shadcn/ui (Radix UI)
- Icons: Lucide React
- PDF Rendering: react-pdf
Backend
- MCP Server: Python FastMCP
- MCP Client: TypeScript MCP SDK
- LLM: Anthropic Claude API (Opus, Sonnet, Haiku)
- HTTP Client: httpx (Python), fetch (TS)
Development Tools
- Package Manager: pnpm
- Testing: Vitest 4+ with Testing Library
- Linting: ESLint, Ruff
- Formatting: Prettier, Black
🎨 UI Components
Built with shadcn/ui and Lucide React icons:
DocumentCard- Individual document displayDocumentList- Grid of document cardsDocumentPreviewModal- Abstract viewerFullDocumentViewer- Complete PDF rendererSummaryGenerationPanel- Summary controlsFormatConversionPanel- Conversion controlsElicitationDialog- Adaptive preference gathering
🔑 MCP Implementation Highlights
Roots
Exposes reformatted-docs/ directory to MCP server:
{
uri: 'file:///reformatted-docs',
name: 'reformatted-documents'
}
Sampling
Provides LLM access for summary generation:
await client.createMessage({
messages: [{ role: 'user', content: 'Summarize...' }]
})
Elicitation
Adaptive prompts based on document size:
if page_count > 50:
preferences = await client.elicitation.create(
message="Configure summary options:",
schema={...}
)
🗺️ Project Structure
afrotech-cac-dv/
├── src/
│ ├── app/ # Next.js app router
│ ├── components/ # React components
│ │ ├── ui/ # shadcn components
│ │ ├── documents/ # Document components
│ │ └── mcp/ # MCP components
│ ├── lib/
│ │ ├── mcp-client/ # MCP client implementation
│ │ └── utils/ # Utilities
│ ├── types/ # TypeScript types
│ └── store/ # State management
├── server/ # MCP Server (Python)
│ ├── main.py
│ ├── tools/
│ ├── provider/ # PDF provider connector
│ └── tests/
├── docs/ # Documentation
├── tests/ # E2E & integration tests
├── reformatted-docs/ # Converted documents
└── public/ # Static assets
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat: add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Commit Convention
Follow Conventional Commits:
feat:New featurefix:Bug fixdocs:Documentationtest:Testingrefactor:Code refactoring
📊 Development Status
Overall Progress: 96% Complete (49/51 tasks)
Completed ✅
- Project setup and architecture
- MCP Client implementation (roots, sampling, elicitation)
- MCP Server implementation (6 tools with FastMCP)
- UI components (7 components with shadcn/ui)
- Document list view with metadata
- Preview modal with abstracts
- Full document viewer with tabs
- AI-powered summary generation
- Format conversion (EPUB, Markdown)
- Testing suite (250 tests, ~75% coverage)
- Comprehensive documentation (10 docs, ~160KB)
- Tailwind CSS v4 migration
- Next.js 15+ compatibility
- Mock mode for development
- Error boundaries and handling
- API routes (6 endpoints)
- Git repository with incremental commits
In Progress / Optional ⏳
- [~] MCP Client roots module tests (technical debt - fs mocking)
- [~] MCP Server Python/pytest tests (optional for UI development)
📋 Want to help complete these? See for a detailed step-by-step plan (5-7 hours).
Production Ready 🚀
The application is production-ready with:
- ✅ All core features working
- ✅ Comprehensive testing
- ✅ Modern tooling (Next.js 15, Tailwind v4)
- ✅ Complete documentation
- ✅ Error handling and recovery
- ✅ Mock mode for development
See for detailed progress tracking.
🐛 Known Issues
Technical Debt
-
MCP Client roots module tests - fs module mocking complexity in Vitest
- Status: Excluded from test suite
- Impact: Low (functionality works, just not unit tested)
- Future: Refactor to dependency injection or use better mocking
-
jsdom Limitations - 3 tests skipped due to browser API limitations
- Clipboard API (2 tests in SummaryGenerationPanel)
- scrollIntoView (1 test in ElicitationDialog)
- Impact: None (features work in browser, just can't unit test)
Browser Compatibility
- Modern browsers only (Chrome 90+, Firefox 88+, Safari 14+)
- Requires JavaScript enabled
- Recommended: Latest version of Chrome, Firefox, or Safari
📝 License
- See LICENSE file for details
🙏 Acknowledgments
- Model Context Protocol - MCP Specification
- FastMCP - FastMCP Library
- Anthropic - Claude AI API
- shadcn/ui - Component library
- Vercel - Next.js framework
📧 Contact
For questions or support, please open an issue on GitHub.
Built with ❤️ using Next.js, MCP, and Claude AI