Skip to content

I Built a Document Research Agent in 15 Minutes — Here's How

March 16, 2026 · Tutorial · 8 min read


Imagine uploading a stack of contracts, research papers, or financial reports — then just asking questions about them in plain English. No manual searching, no Ctrl+F, no reading 50 pages to find one clause.

That's exactly what I built on Universal API in about 15 minutes. Here's how.

The Problem

I had a stack of documents I needed to analyze:

  • A 30-page commercial lease agreement
  • Two vendor contracts with different terms
  • A market research report from a consulting firm

I needed to answer questions like:

  • "What are my termination rights across all these contracts?"
  • "How do the payment terms compare between vendor A and vendor B?"
  • "What does the market research say about pricing trends in Q4?"

Normally this would take hours of reading. With an AI agent connected to my documents, it took seconds per question.

What We're Building

An AI agent that:

  1. Reads your uploaded documents via Universal API's Knowledge storage (with semantic search)
  2. Searches the web for additional context (via the Doc Hound MCP server)
  3. Answers your questions with citations back to specific documents

The architecture looks like this:

You → Agent → Knowledge MCP (your docs) + Doc Hound MCP (web search)
                    ↓                           ↓
            Semantic search across        Google search +
            your uploaded files           web page scraping

Prerequisites

  • A Universal API account (free tier works — 100 credits)
  • A Bearer token (create one on the Credentials page)
  • Some documents to analyze (PDFs, text files, Word docs)

Step 1: Upload Your Documents

First, upload your documents to Knowledge storage. You can do this through the UI or the API.

Via the UI: Navigate to the Knowledge page and drag-and-drop your files.

Via the API:

bash
# Get a presigned upload URL
curl -s -X POST https://api.universalapi.co/knowledge/upload-url \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fileName": "lease-agreement.pdf", "contentType": "application/pdf"}' | jq

# Upload the file
curl -X PUT -H "Content-Type: application/pdf" \
  --data-binary @lease-agreement.pdf \
  "PRESIGNED_URL_FROM_ABOVE"

Repeat for each document. Universal API automatically:

  • Extracts text from PDFs (via OCR if needed)
  • Chunks the content into semantic segments
  • Embeds each chunk using AWS Bedrock Titan Embeddings
  • Indexes everything for semantic search

Within seconds, your documents are searchable by meaning, not just keywords.

Step 2: Create the Agent

Now create an agent that connects to your Knowledge and to web search. Here's the source code:

python
import os
from strands import Agent
from strands.models.bedrock import BedrockModel
from strands.tools.mcp import MCPClient
from strands.tools.mcp.mcp_client import StreamableHTTPTransport

def create_agent():
    # Use Claude Sonnet for reasoning
    model = BedrockModel(
        model_id="us.anthropic.claude-sonnet-4-20250514-v1:0",
        region_name="us-east-1"
    )

    # Get auth token from environment (auto-injected by UAPI)
    bearer_token = os.environ.get("UNIVERSALAPI_BEARER_TOKEN", "")

    # Connect to Universal API MCP server (includes Knowledge search)
    uapi_transport = StreamableHTTPTransport(
        url="https://api.universalapi.co/mcp/96303dd2-d86f-4df0-ad94-1b8bce625535",
        headers={"Authorization": f"Bearer {bearer_token}"}
    )
    uapi_mcp = MCPClient(transport=uapi_transport)

    # Connect to Doc Hound MCP server (web search + scraping)
    dochound_transport = StreamableHTTPTransport(
        url="https://api.universalapi.co/mcp/YOUR_DOCHOUND_SERVER_ID",
        headers={"Authorization": f"Bearer {bearer_token}"}
    )
    dochound_mcp = MCPClient(transport=dochound_transport)

    system_prompt = """You are a document research assistant. You help users 
    analyze their uploaded documents and find information across them.

    Your capabilities:
    - Search the user's Knowledge storage for relevant document sections
    - Search the web for additional context and comparisons
    - Synthesize information from multiple sources

    When answering questions:
    1. Always search the user's Knowledge first for relevant document sections
    2. If the user asks for comparisons or external context, also search the web
    3. Cite your sources — mention which document or URL the information came from
    4. If you're unsure, say so rather than guessing
    """

    agent = Agent(
        model=model,
        tools=[uapi_mcp, dochound_mcp],
        system_prompt=system_prompt,
        session_manager=session_manager  # Enables multi-turn conversations
    )

    return agent, [uapi_mcp, dochound_mcp]

Deploy this agent via the Universal API UI or API:

bash
curl -X POST https://api.universalapi.co/agent/create \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agentName": "document-researcher",
    "description": "Analyzes uploaded documents and answers questions with citations",
    "sourceCode": "... (the Python code above) ...",
    "visibility": "private"
  }'

Step 3: Ask Questions

Now chat with your agent:

bash
curl -X POST https://stream.api.universalapi.co/agent/YOUR_AGENT_ID/chat \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "What are my termination rights in the lease agreement?"}'

The agent will:

  1. Search your Knowledge storage for sections about termination
  2. Find the relevant clauses across your uploaded documents
  3. Synthesize an answer with citations

Example response:

Based on your lease agreement (lease-agreement.pdf), you have the following termination rights:

  1. Early termination with penalty (Section 12.3): You may terminate with 90 days written notice and payment of 3 months' rent as a termination fee.
  2. Termination for cause (Section 12.5): If the landlord fails to maintain the premises per Section 8, you may terminate with 30 days notice after providing written notice of the deficiency.
  3. Mutual termination (Section 12.7): Both parties may agree to terminate at any time in writing.

Note: The lease does NOT include a standard "kick-out clause" based on revenue thresholds, which is common in commercial leases. You may want to negotiate this for your next renewal.

That last insight — comparing your lease to standard practices — comes from the agent searching the web for commercial lease norms. That's the power of combining your private documents with public knowledge.

Real-World Use Cases

This same pattern works for:

Use CaseUpload TheseAsk This
Legal reviewContracts, agreements"What are the liability caps across all vendor contracts?"
Due diligenceFinancial statements, filings"What's the revenue trend over the last 3 years?"
Academic researchPapers, studies"What do these papers say about the effectiveness of X?"
Competitive analysisCompetitor docs, earnings reports"How does Company A's pricing compare to Company B?"
CompliancePolicies, regulations"Are we compliant with Section 4.2 of the regulation?"

What It Costs

On Universal API's free tier (100 credits):

  • Uploading documents: Free
  • Each agent chat message: ~5-15 credits (depends on the model and how many tools it uses)
  • Knowledge search: 1 credit per search
  • Web search: 1 credit per search

So you can ask roughly 10-20 questions on the free tier. The Starter plan ($29/month) gives you 30,000 credits — enough for thousands of research queries.

For context, a paralegal charges $75-150/hour for document review. A single month of Universal API costs less than 30 minutes of paralegal time.

What's Next

This is just the beginning. You could extend this agent to:

  • Extract structured data from documents using Textract OCR
  • Generate comparison tables across multiple contracts
  • Monitor for changes by re-uploading updated documents
  • Share with your team by making the agent public or sharing your UAPI workspace

Try It Yourself

  1. Sign up for Universal API (free, 100 credits)
  2. Upload a few documents to Knowledge
  3. Create an agent with the code above (or use our pre-built Document Research agent)
  4. Start asking questions

The whole setup takes about 15 minutes. The time you'll save? That depends on how many documents you're drowning in.


Have questions or want to share what you built? Find us on GitHub.

Universal API — The agentic entry point to the universe of APIs