PETSc RAG MCP server#

http://mcp.petsc-ai.org:8082/mcp or https://mcp.petsc-ai.org:8445/mcp

Provides a MCP agent that provides RAG context for a prompt related to PETSc

Purpose#

The purpose of this MCP agent is to enable the implementation of “higher-level” PETSc MCP agents that use high-quality PETSc appropriate context without needing to implement the RAG infrastructure themselves.

Usage#

The MCP agent may be tested from the command line using

python petsc_rag_mcp_client.py  [--stdio] [--url PETSC_MCP_SERVERS_URL] --get_documentation_rag_prompt request

or

python petsc_rag_mcp_client.py  [--stdio] [--url PETSC_MCP_SERVERS_URL] --get_developer_rag_prompt request

The client Python file also contains a PetscRAGMCPClient() class that connects to the server and has a (mirror) method for each tool provided by the server. This class can be used when writing new MCP agents that need to utilize RAG.

To start the MCP server locally

PETSC_DIR=xxx PETSC_ARCH=yyy python NVIDIA_API_KEY=zzz  petsc_rag_mcp_server.py [--stdio]

The RAG vector databases are created with

PETSC_DIR=xxx PETSC_ARCH=yyy python NVIDIA_API_KEY=zzz petsc_rag_mcp_generate_data.py

Limitations#

This currently uses the nvidia/nv-embed-v1 embedding by default because that is the best one I could get working in a portable, open source environment. It would be better to default to a better embedding (the cost is not the issue). This currently uses nv-rerank-qa-mistral-4b:1 for reranking, perhaps better rerankers are available.