tiwater/supen-edit
If you are the rightful owner of supen-edit 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.
MCP server for document editing and visualization in the Supen ecosystem.
Supen Edit
A Model Context Protocol (MCP) server with HTTP API and interactive playground for testing document management tools.
Features
šÆ Document Editor
- Word-Style Formatting: Bold, italic, underline, headings
- Structure Tools: Headers (H1-H3), bullet lists, numbered lists
- Real-time Statistics: Word count, character count, paragraph count
- Document Analysis: Structure parsing and content insights
- Version History: Track document changes over time
š¤ MCP Server Integration
- Built-in MCP API: HTTP endpoints with streaming support
- Document Management: Create, read, update, delete documents
- Document Structure Parsing: Extract sections, paragraphs, tables
- Search & Analysis: Full-text search within documents
- Version Control: Track document changes and history
- Comments System: Add and manage document comments
- DOCX Support: Native Microsoft Word document processing
š Web Interface
- Modern Design: Responsive design with dark/light mode support
- MCP Playground: Two modes for testing MCP functionality:
- Tool Call Mode: Direct tool testing with examples
- Chat Mode: Natural language interface powered by DeepSeek
- API Documentation: Interactive documentation with examples
- Document Viewer: Integrated viewer with iframe embedding support
- Real-time Updates: Live document preview and updates
Quick Start
1. Install Dependencies
pnpm install
2. Configure Environment Variables (Optional)
For chat mode functionality, create a .env.local
file:
cp .env.example .env.local
Then add your DeepSeek API key:
DEEPSEEK_API_KEY=your_api_key_here
3. Run Development Server
pnpm dev
Visit http://localhost:3301 to access the document editor.
4. Generate API Documentation
pnpm generate:docs
Then visit http://localhost:3301/docs to view the interactive API documentation.
MCP API Usage
The MCP server is available through HTTP endpoints:
Initialize Connection
curl -X POST http://localhost:3301/api/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'
List Available Tools
curl -X POST http://localhost:3301/api/mcp/tools/list \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Call a Tool
curl -X POST http://localhost:3301/api/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "create_document",
"arguments": {
"title": "My Document",
"content": "Hello World"
}
}
}'
Streaming API (Server-Sent Events)
const eventSource = new EventSource('/api/mcp/stream');
eventSource.onmessage = (event) => {
console.log('Received:', JSON.parse(event.data));
};
Available MCP Tools
Tool | Description |
---|---|
create_document | Create a new document with optional content |
get_document | Retrieve a document by ID |
update_document | Update document content and increment version |
list_documents | List all documents with metadata |
delete_document | Delete a document and all its versions |
parse_document_structure | Extract document structure (sections, paragraphs) |
search_document | Search for text within a document |
get_document_versions | Get version history for a document |
add_comment | Add a comment to a specific location |
get_comments | Retrieve all comments for a document |
resolve_comment | Mark a comment as resolved |
Project Structure
supen-edit/
āāā src/
ā āāā app/
ā ā āāā api/
ā ā ā āāā mcp/ # MCP server endpoints
ā ā āāā docs/ # API documentation page
ā ā āāā page.tsx # Main editor interface
ā āāā components/ # React components
ā āāā hooks/ # Custom React hooks
ā āāā lib/ # Utility functions and document processor
ā āāā types/ # TypeScript type definitions
āāā public/
ā āāā api-docs/ # Generated API documentation
āāā scripts/
ā āāā generate-tool-docs.ts # Documentation generator
āāā package.json
Development
Available Scripts
pnpm dev
- Start development serverpnpm build
- Build for productionpnpm start
- Run production buildpnpm lint
- Run ESLintpnpm generate:docs
- Generate API documentation
Technology Stack
- Next.js 15: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS v4: Modern CSS framework
- shadcn/ui: Beautiful, accessible UI components
- @modelcontextprotocol/sdk: Official MCP SDK
- docx: Microsoft Word document processing
- mammoth: DOCX to HTML/text conversion
Using with AI Assistants
While the built-in HTTP API makes it easy to integrate with any system, you can also use it with AI assistants that support HTTP-based MCP servers.
Example Integration
// Example client code
const mcpClient = {
async callTool(name, params) {
const response = await fetch('http://localhost:3301/api/mcp/tools/call', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: Date.now(),
method: 'tools/call',
params: { name, arguments: params }
})
});
const data = await response.json();
return JSON.parse(data.result.content[0].text);
}
};
// Use the client
const doc = await mcpClient.callTool('create_document', {
title: 'My Document',
content: 'Hello World'
});
Document Viewer (Iframe Embedding)
The document viewer can be embedded as an iframe to display documents in other applications:
<iframe
src="http://localhost:3301/viewer?id=doc_123"
width="100%"
height="600"
frameborder="0"
></iframe>
The viewer provides a clean, read-only interface for displaying documents with:
- Document title and metadata
- Version information
- Formatted content rendering
- Dark/light mode support
- No navigation chrome (designed for embedding)
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
License
MIT License - see file for details.