June 4, 2025
TLDR
We’re continuing our goal to build “Attractor,” an AI system that answers questions about Space and Physics using a research paper by Christopher Cillian O’neill, “Evidence of the Great Attractor and Great Repeller from Artificial Neural Network Imputation of Sloan Digital Sky Survey.” In Part I, we built the data foundation, extracting, cleaning, and chunking PDF content to prepare it for AI integration.
In Part II we’ll focus on implementing an intelligence layer that connects the processed documents to Anthropic’s API through a Model Context Protocol (MCP) server. We’ll implement the core functionality where an MCP server manages document search and retrieval, then sends relevant content to Claude for analysis. The we’ll return an intelligent answer.
Table of contents
Introduction
Understanding MCP in practice
Implement an MCP server in Mage Pro
Call Anthropic’s Claude
Export the answer for external systems
Conclusion
Introduction
In Part I, we built the data processing foundation of our Model Context Protocol (MCP) pipeline - extracting, cleaning, and chunking PDF content about the Great Attractor. Now we'll bring our "Attractor" AI to life by integrating Anthropic's Claude API. Part II focuses on the intelligence layer where we’ll connect our processed document chunks to Claude through an MCP server. Instead of relying on Claude's general training data, our AI will answer questions based strictly on the research paper we processed. This will create more reliable and traceable responses which is perfect for internal or external business applications that need to answer questions from company knowledge assets.

Understanding MCP in practice
Unlike traditional RAG that directly embed and query document chunks, leveraging MCP creates a structured, server-client architecture for document interaction. Attractor, the name of our AI tool, acts as a dedicated document service that organizes PDF chunks into searchable content. It provides tools that can understand questions and find relevant answers from the document.
When a question is asked, the process follows the MCP protocol in several steps:
Connection: The client establishes a JSON-RPC connection with the document server
Discovery: The client discovers available tools and resources from the server
Search: The query is processed through the search tool to find relevant chunks
Retrieval: Specific chunks are retrieved using their resource URIs
Analysis: The retrieved content is sent to Claude via the Anthropic API for final analysis
Taking this approach separates the document handling from the AI Processing and follows the new MCP standard. It will work well with other tools and only send the most relevant document sections to Claude. This will save costs and give better answers. Check out the code below to build you MCP server if you are following along with this project:
Implement an MCP server in Mage Pro
Once you’ve written or copied the code above you’ll need to create and store a file in Mage Pro for your pipeline to reference. Take the following steps to complete this process:
Navigate to your folders in Mage Pro and right click on the folder where you want to store the new python file
Give the python file a name similar to
mcp_document_server.py
Click on the new file to open it in the editor and then copy on the MCP server code from above.
Save the file.
You may need to adjust the code in the Call Anthropic’s Claude section depending on where you stored the file, and what you named the file.
The line of code where you refer to the file starts on lines 17 and 24 of the code. You will need to adjust the file path to match where you saved the MCP document server code.
Once you complete the steps above you can add a new block of code that will call anthropic to return an analytical answer based on the document provided.
Call Anthropic’s Claude
The final transformation block serves as the intelligence layer of our MCP system. it orchestrates communication between the processed document chunks and the Anathropic API. This block:
Establishes a JSON → RPC connection with the MCP server
Searches for relevant document chunks using the "search_document" tool
Retrieves specific content through resource URIs
Sends the retrieved document content to Claude with explicit instructions to answer questions strictly based on the provided PDF context
Prevents the AI from using external knowledge outside the document
Returns a structured response containing the original question, Claude's document-grounded analysis, and method metadata
This creates a complete audit trail from source document to AI-generated insights that exemplifies the core principles of MCP.
Export the answer for external systems
For production pipelines, the data exporter block can serve as a gateway to write data to multiple locations if needed. Data can be written to:
Vector database storage: store your responses in a vector database to build a searchable knowledge base of previously answered questions.
Caching layer: cache your responses in Redis using question hashes to improve response times for repeat questions
Analytics pipeline: export responses to data warehouses like Snowflake or BigQuery to track performance metrics over time.
This clean separation between processing and output ensures that our AI system can integrate seamlessly with various downstream applications, from notebooks to web interfaces, making the knowledge contained in our PDF document accessible through a simple, consistent API response format.
Conclusion
MCP powered document analysis is a significant improvement over traditional RAG approaches because it implements structured protocols for document interaction. The separation between document handling and AI processing creates more reliable responses. It also maintains clear traceability from source material through final analysis.
Some key advantages include:
Document-constrained AI responses that prevent hallucination by grounding Claude's analysis in specific source material
Modular architecture that scales across multiple documents and use cases
Seamless integration with existing business systems and workflows
Trustworthy knowledge systems for internal research, customer support, and decision-making processes
Whether you are processing research papers, creating a chat bot based on technical documentation, or building internal knowledge bases from proprietary business documents, this MCP approach provides the reliability and transparency that production AI applications will need.
Want to build a RAG pipeline using MCP methods discussed above? Schedule a free demo with Mage to get started today.