A Model Context Protocol (MCP) server for semantic search over political resolutions (Beschlüsse) from Grüne Hamburg. Built with Spring Boot and pgvector for vector similarity search.
- Semantic Search: Find relevant resolutions using natural language queries
- Document-specific Search: Search within a specific resolution document
- Document Listing: List all available resolution documents
- Vector Similarity: Uses pgvector with cosine similarity for accurate results
- Docker and Docker Compose
- Mistral AI API key (for query embeddings)
- Node.js (for Claude Desktop integration via mcp-remote)
git clone https://github.com/KyleKreuter/green-mcp.git
cd green-mcpCreate a .env file with your Mistral AI API key:
nano .env
# Edit .env and add your MISTRAL_API_KEYThe server requires pre-computed embeddings to function. Place these files in src/main/resources/data/:
embeddings.csv- Contains document chunks with embeddingsmetadata.csv- Contains metadata for each chunk
CSV Format for embeddings.csv:
"id","pdf_url","chunk_index","content","embedding"
"uuid","https://...","0","Text content here","[0.1, 0.2, ...]"
CSV Format for metadata.csv:
"id","filename","title","topic","sequence_number","word_count","created_at"
"uuid","document.pdf","Title","Topic","0","150","2024-01-01T00:00:00"
Note: Embeddings must be 1024-dimensional vectors (Mistral AI embedding format).
To obtain the Grüne Hamburg embeddings dataset, please contact me.
To create your own embeddings, use the Mistral AI Embeddings API.
docker compose up -d --buildThe MCP server will be available at http://localhost:2228/sse
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"green-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:2228/sse"]
}
}
}Restart Claude Desktop to load the MCP server.
Search across all resolutions using semantic similarity.
Parameters:
query(string): Natural language search querylimit(integer, optional): Number of results (1-20, default: 5)
Example: "Find resolutions about climate protection"
Search within a specific resolution document.
Parameters:
beschlussName(string): Filename or part of filenamequery(string): Natural language search querylimit(integer, optional): Number of results (1-20, default: 5)
Example: Search for "renewable energy" in "Wahlprogramm-2024.pdf"
List all available resolution documents.
Parameters: None
Returns: List of all document filenames
┌─────────────────┐ ┌──────────────────┐ ┌─────────────┐
│ Claude Desktop │◄──SSE──►│ Spring Boot │◄───────►│ PostgreSQL │
│ (MCP Client) │ │ MCP Server │ │ + pgvector │
└─────────────────┘ └──────────────────┘ └─────────────┘
│
▼
┌──────────────────┐
│ Mistral AI │
│ (Embeddings) │
└──────────────────┘
Data Flow:
- User query → Mistral AI → Query embedding (1024 dim)
- Query embedding → pgvector cosine similarity search
- Top-K results → MCP response to Claude
# Start only PostgreSQL
docker compose up -d postgres
# Run Spring Boot locally
MISTRAL_API_KEY=your-key ./mvnw spring-boot:run./mvnw test./mvnw package -DskipTests| Variable | Description | Required |
|---|---|---|
MISTRAL_API_KEY |
Mistral AI API key for embeddings | Yes |
SPRING_DATASOURCE_URL |
PostgreSQL connection URL | No (default in Docker) |
SPRING_DATASOURCE_USERNAME |
Database username | No (default: greenmcp) |
SPRING_DATASOURCE_PASSWORD |
Database password | No (default: greenmcp) |
Key settings in application.properties:
server.port=2228
spring.ai.mcp.server.sse-message-endpoint=/mcp/message
spring.jpa.hibernate.ddl-auto=updateTo use this MCP server with your own documents:
- Extract text from your PDF documents
- Chunk the text into meaningful segments (recommended: 200-500 words per chunk)
- Generate embeddings using Mistral AI's embedding API:
from mistralai.client import MistralClient
client = MistralClient(api_key="your-key")
response = client.embeddings(
model="mistral-embed",
input=["Your text chunk here"]
)
embedding = response.data[0].embedding # 1024-dimensional vector- Create CSV files in the required format (see above)
- Place files in
src/main/resources/data/
MIT
For questions about the Grüne Hamburg embeddings dataset or this project, please open an issue.