korshak1962/mcp-knowledge-server
If you are the rightful owner of mcp-knowledge-server 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.
The MCP Knowledge Server is a Spring Boot application designed to provide intelligent access to a knowledge store with enhanced metadata capabilities, facilitating efficient file discovery and management.
list_files
List all files in the knowledge store.
read_file
Read the content of a specific file.
search_files
Search for files containing specific text.
get_file_info
Get metadata about a file.
write_file
Write content to a file.
MCP Knowledge Server with Enhanced Metadata
A Model Context Protocol (MCP) server built with Spring Boot that provides intelligent access to a knowledge store with rich metadata capabilities for efficient file discovery and large file handling.
š Key Features
- Smart Metadata System: Rich file descriptions, tags, categories, and summaries
- Large File Intelligence: Automatic detection and handling of files that exceed context limits
- Multi-format Support: Handles text files, PDFs, images, and more using Apache Tika
- MCP Protocol: Full MCP 2024-11-05 protocol implementation
- WebSocket Interface: Real-time communication via WebSocket
- REST API: Additional HTTP endpoints for testing and file uploads
- Intelligent Search: Search by content OR metadata (tags, descriptions, categories)
- Category Auto-detection: Automatic file categorization
- Spring Boot: Built on robust Spring Boot framework
šÆ Problem Solved: Large File Context Management
This server intelligently handles the challenge of large files exceeding Claude's context window:
- Metadata First: Claude can see file descriptions and summaries without reading full content
- Size Warnings: Files >50KB are flagged with recommendations to read summaries first
- Smart Discovery: Find relevant files through metadata search before content search
- Category Navigation: Organize and discover files by type
š Two Transport Options Available
š for detailed setup
Option 1: Web/WebSocket Version (for testing/development)
- WebSocket:
ws://localhost:8080/mcp
- REST API:
http://localhost:8080/api/knowledge/
- Command:
start-web-server.bat
Option 2: Stdin/Stdout Version (for Claude Desktop)
- Direct stdin/stdout communication
- Add to Claude Desktop MCP configuration
- Command:
start-stdin-server.bat
Quick Start
Prerequisites
- Java 17 or higher
- Maven 3.6 or higher
Building and Running
-
Clone or navigate to the project directory:
cd D:\mcp-knowledge-server
-
Build the project:
mvn clean install
-
Run the server:
mvn spring-boot:run
Or run the JAR directly:
java -jar target/mcp-knowledge-server-1.0.0.jar
-
Server will start on port 8080
Testing the Server
Health Check:
curl http://localhost:8080/api/knowledge/health
List Files:
curl http://localhost:8080/api/knowledge/files
Upload a File:
curl -X POST -F "file=@your-file.txt" http://localhost:8080/api/knowledge/upload
MCP Protocol Usage
WebSocket Endpoint
ws://localhost:8080/mcp
Available Tools
-
list_files: List all files in the knowledge store
{ "jsonrpc": "2.0", "id": "1", "method": "tools/call", "params": { "name": "list_files", "arguments": {} } }
-
read_file: Read the content of a specific file
{ "jsonrpc": "2.0", "id": "2", "method": "tools/call", "params": { "name": "read_file", "arguments": { "filename": "welcome.md" } } }
-
search_files: Search for files containing specific text
{ "jsonrpc": "2.0", "id": "3", "method": "tools/call", "params": { "name": "search_files", "arguments": { "query": "your search term" } } }
-
get_file_info: Get metadata about a file
{ "jsonrpc": "2.0", "id": "4", "method": "tools/call", "params": { "name": "get_file_info", "arguments": { "filename": "welcome.md" } } }
-
write_file: Write content to a file
{ "jsonrpc": "2.0", "id": "5", "method": "tools/call", "params": { "name": "write_file", "arguments": { "filename": "new-file.txt", "content": "Your content here" } } }
Project Structure
D:\mcp-knowledge-server\
āāā src/
ā āāā main/
ā ā āāā java/com/example/mcpserver/
ā ā ā āāā McpKnowledgeServerApplication.java
ā ā ā āāā McpWebSocketHandler.java
ā ā ā āāā controller/
ā ā ā ā āāā KnowledgeStoreController.java
ā ā ā āāā handler/
ā ā ā ā āāā McpProtocolHandler.java
ā ā ā āāā model/
ā ā ā ā āāā McpMessage.java
ā ā ā ā āāā McpError.java
ā ā ā ā āāā Tool.java
ā ā ā ā āāā ToolCallResult.java
ā ā ā āāā service/
ā ā ā āāā KnowledgeStoreService.java
ā ā āāā resources/
ā ā āāā application.properties
ā āāā test/
āāā knowledgeStore/ # Your knowledge files go here
ā āāā welcome.md
ā āāā setup-instructions.txt
āāā pom.xml
āāā README.md
Configuration
Edit src/main/resources/application.properties
to customize:
server.port
: Server port (default: 8080)knowledge.store.path
: Path to knowledge store (default: ./knowledgeStore)- Logging levels and other Spring Boot settings
Supported File Types
- Text files: .txt, .md
- PDF files: .pdf (using Apache PDFBox)
- Images: .jpg, .jpeg, .png, .gif (metadata extraction)
- Office documents: .docx, .xlsx, .pptx (using Apache Tika)
- And many more through Apache Tika's extensive format support
Dependencies
- Spring Boot 3.2.0
- Apache PDFBox 3.0.1 (PDF processing)
- Apache Tika 2.9.1 (Multi-format document processing)
- Apache Commons IO 2.15.1 (File operations)
- Jackson (JSON processing)
Development
To extend the server:
- Add new tools in
McpProtocolHandler
- Implement business logic in
KnowledgeStoreService
- Add REST endpoints in
KnowledgeStoreController
if needed - Update the tool schemas in the
handleToolsList
method
License
This project is provided as-is for educational and development purposes.