Tutorial ยท Claude API Integration

How to Build a Claude-Powered Internal Knowledge Base for Your Company

Most company knowledge is trapped. It lives in Confluence pages nobody visits, SharePoint folders buried three clicks deep, Slack threads that evaporate after 90 days, and the heads of your most experienced engineers. When someone leaves or a new hire joins, that institutional memory either walks out the door or requires weeks of shadow learning to recover.

A Claude-powered internal knowledge base changes this. Instead of building a static document repository and hoping people search it, you build a retrieval-augmented system where Claude reads your company's documentation in real time and answers questions with citations. It's the difference between a filing cabinet and a knowledgeable colleague.

This guide walks through the complete architecture: document ingestion, vector storage, Claude API integration, retrieval logic, and enterprise deployment. If you're evaluating whether this is the right system for your organisation, book a free strategy call with our Claude Certified Architects before you start building.

The Architecture: RAG vs MCP vs Both

Before writing a single line of code, you need to decide how Claude will access your company knowledge. There are three main patterns, each suited to different scales and organisational requirements.

Pattern 1: Retrieval-Augmented Generation (RAG)

Classic RAG works by chunking your documents into small passages, embedding them into a vector store (Pinecone, Weaviate, pgvector), and at query time, retrieving the top-k most relevant passages and passing them to Claude as context. Claude answers the question based on what you retrieved. This is the right approach for large, relatively static document corpora โ€” policy manuals, technical specifications, compliance documentation, product wikis.

Pattern 2: MCP Server with Live Document Access

The Model Context Protocol (MCP) lets Claude call tools that fetch documents in real time. Instead of pre-embedding everything, you build MCP servers that can search Confluence, query SharePoint, pull from Google Drive, or hit your internal APIs. Claude uses tool calls to retrieve exactly what it needs per query. This is better for frequently-updated content where stale embeddings would be a problem. Our MCP server development service has built these connectors across dozens of enterprise document systems.

Pattern 3: Hybrid (Recommended for Enterprise)

Most production enterprise knowledge bases use both. RAG handles the broad semantic search over large corpora; MCP tools handle live lookups for things like "what did we decide in the product meeting last week?" or "what's the current status of this Jira ticket?" The Claude API orchestrates both paths, deciding at runtime which retrieval strategy to invoke based on the query.

Architecture decision rule: If your knowledge changes less than once a week, RAG alone is fine. If key content updates daily or you need live system data, add MCP. If you need both search and actions (create a ticket, update a document), MCP is essential.

Step 1: Document Ingestion Pipeline

The quality of your knowledge base is entirely determined by how well you ingest documents. Poor ingestion โ€” wrong chunk sizes, lost metadata, no update mechanism โ€” produces a system that confidently gives wrong answers.

Chunking Strategy

Most developers default to fixed-size chunking (e.g., every 500 tokens). This is wrong for enterprise documentation. Technical runbooks split mid-procedure; meeting notes lose context. Use semantic chunking instead: chunk at paragraph boundaries, preserve section headers as metadata, and keep chunks between 200 and 800 tokens with 10โ€“15% overlap between adjacent chunks.

import anthropic
from langchain.text_splitter import RecursiveCharacterTextSplitter

def chunk_document(text: str, source: str, doc_type: str) -> list[dict]:
    splitter = RecursiveCharacterTextSplitter(
        chunk_size=600,
        chunk_overlap=80,
        separators=["\n\n", "\n", ". ", " "]
    )
    chunks = splitter.split_text(text)
    return [
        {
            "content": chunk,
            "metadata": {
                "source": source,
                "doc_type": doc_type,   # "policy", "runbook", "meeting", "spec"
                "chunk_index": i,
                "total_chunks": len(chunks)
            }
        }
        for i, chunk in enumerate(chunks)
    ]

Metadata Schema

Every chunk must carry metadata that enables filtered search. At minimum: document source URL, document type, author, last-modified date, and access tier (public, team-confidential, exec-only). The access tier is critical for enterprise deployments โ€” you don't want sales reps retrieving finance strategy documents because they happened to be semantically similar to a customer question.

Update Pipeline

Document ingestion is not a one-time job. Build a scheduled pipeline (nightly is usually sufficient) that detects changed documents via modification timestamps, re-chunks and re-embeds them, and replaces the old vectors in your store. If you're pulling from Confluence or SharePoint, their APIs expose a modifiedSince parameter for this. Track ingestion timestamps per document ID in a metadata table so you can audit what's current.

Building this at scale?

Our Claude API Integration service has deployed knowledge base pipelines for organisations with 50,000+ documents. We handle ingestion, deduplication, access controls, and the Claude integration layer.

Book a Free Strategy Call โ†’

Step 2: Vector Store Setup

For enterprise deployments, vector store selection depends less on performance and more on where your data is allowed to live. If you're in a regulated industry, you may need a self-hosted option. If you're cloud-native, a managed service is faster to ship.

Cloud-Managed Options

Pinecone is the most popular for Claude RAG workloads โ€” it has a serverless tier, clean Python SDK, and good filtering support. Weaviate Cloud is strong if you need hybrid search (vector + BM25 keyword). pgvector on RDS is the right call if your team already operates PostgreSQL and doesn't want to manage another data store โ€” it's slower at large scale but operationally simpler.

Self-Hosted Options

For financial services, healthcare, and government organisations where data cannot leave your cloud tenant: deploy Qdrant on EKS/GKE, or use pgvector on self-managed PostgreSQL. Both are battle-tested for million-document corpora. See our guide on building Claude RAG systems for detailed Pinecone setup and our database MCP tutorial for connecting Claude to self-hosted stores.

Embedding Model Selection

Use text-embedding-3-large from OpenAI or Voyage-3-large (recommended by Anthropic for Claude workflows) for embedding. Voyage-3-large outperforms OpenAI embeddings on enterprise retrieval benchmarks, particularly for technical and legal text. At query time, embed the user's question with the same model and compute cosine similarity against your stored vectors.

import voyageai

voyage = voyageai.Client()

def embed_query(query: str) -> list[float]:
    result = voyage.embed([query], model="voyage-3-large")
    return result.embeddings[0]

def embed_chunks(chunks: list[str]) -> list[list[float]]:
    result = voyage.embed(chunks, model="voyage-3-large", input_type="document")
    return result.embeddings

Step 3: Claude API Integration

With documents ingested and retrievable, now you integrate Claude. The core pattern is: receive user question โ†’ retrieve top-k chunks โ†’ pass chunks + question to Claude โ†’ stream response with citations.

The Retrieval + Generation Loop

import anthropic

client = anthropic.Anthropic()

def answer_question(question: str, user_access_tier: str) -> str:
    # 1. Embed the question
    query_embedding = embed_query(question)

    # 2. Retrieve top-5 chunks (filtered by access tier)
    results = vector_store.query(
        vector=query_embedding,
        top_k=5,
        filter={"access_tier": {"$lte": user_access_tier}}
    )

    # 3. Build context string with citations
    context_parts = []
    for i, match in enumerate(results.matches):
        context_parts.append(
            f"[Source {i+1}: {match.metadata['source']}]\n{match.metadata['content']}"
        )
    context = "\n\n---\n\n".join(context_parts)

    # 4. Call Claude with retrieval context
    message = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=1024,
        system="""You are the internal knowledge assistant for this company.
Answer questions using only the provided context.
Always cite your sources using [Source N] notation.
If the answer is not in the context, say so clearly โ€” do not speculate.""",
        messages=[
            {
                "role": "user",
                "content": f"Context:\n\n{context}\n\n---\n\nQuestion: {question}"
            }
        ]
    )
    return message.content[0].text

Prompt Engineering for Knowledge Retrieval

The system prompt is more important than most developers realise. Tell Claude explicitly to cite sources, to refuse speculation when context is absent, and to indicate confidence level when information seems partial. Without the "if not in context, say so" instruction, Claude will hallucinate plausible-sounding answers โ€” which is catastrophic in a compliance or legal context.

For multi-turn conversations (a chat interface rather than single-query), maintain conversation history and re-retrieve on each turn. Don't assume the context from turn one is still relevant at turn five โ€” user questions evolve. A useful pattern is to have Claude generate a retrieval query from the conversation history before embedding and searching.

Extended Context vs RAG

Claude Opus supports 200K tokens of context. You might wonder: why not just dump your entire knowledge base into the context window? At small scale (a few dozen documents), this works and simplifies the system considerably. At enterprise scale, it becomes expensive and slow โ€” and prompt caching only helps if your document set is stable. RAG remains the right approach for anything over a few hundred thousand tokens of total knowledge, or when documents change frequently. For a deeper architectural analysis, see our guide on RAG architecture with Claude.

Step 4: MCP Server for Live Document Access

If you need Claude to access Confluence, SharePoint, Notion, or internal wikis without pre-embedding everything, an MCP server is the right tool. Instead of retrieval, Claude uses tool calls to search and fetch documents on demand.

Building a Confluence MCP Server

from mcp.server import Server
from mcp.server.models import InitializationOptions
import mcp.types as types
import httpx

app = Server("confluence-knowledge")

@app.list_tools()
async def handle_list_tools() -> list[types.Tool]:
    return [
        types.Tool(
            name="search_confluence",
            description="Search Confluence for pages matching a query",
            inputSchema={
                "type": "object",
                "properties": {
                    "query": {"type": "string", "description": "Search query"},
                    "space_key": {"type": "string", "description": "Optional Confluence space key"}
                },
                "required": ["query"]
            }
        ),
        types.Tool(
            name="get_page_content",
            description="Retrieve full content of a Confluence page by ID",
            inputSchema={
                "type": "object",
                "properties": {
                    "page_id": {"type": "string"}
                },
                "required": ["page_id"]
            }
        )
    ]

@app.call_tool()
async def handle_call_tool(name: str, arguments: dict) -> list[types.TextContent]:
    if name == "search_confluence":
        results = await confluence_search(arguments["query"], arguments.get("space_key"))
        return [types.TextContent(type="text", text=str(results))]
    elif name == "get_page_content":
        content = await get_confluence_page(arguments["page_id"])
        return [types.TextContent(type="text", text=content)]

Once built, deploy this MCP server and connect it to Claude Code or Claude Enterprise. Your employees can then ask "what does our incident response runbook say about P1 database failures?" and Claude will search Confluence in real time, fetch the relevant page, and answer from current content โ€” not from embeddings that might be six weeks stale. See our full MCP server Python tutorial for complete setup instructions.

Step 5: Access Controls and Security

An internal knowledge base without access controls is a data governance liability. The system you build must respect existing permission structures โ€” employees should only see documents they're authorised to see, even when retrieved through Claude.

Row-Level Security in the Vector Store

Every vector in your store should carry access metadata: the user groups or roles permitted to see it. At query time, pass the authenticated user's roles as filter parameters. This keeps access control enforcement in the vector store layer, not in post-retrieval filtering (which is slower and more error-prone).

Authentication Architecture

Integrate your knowledge base API with your existing identity provider. If you're using Azure AD or Okta, require a valid JWT before any knowledge base query is processed. Decode the token, extract the user's groups, and pass those as vector store filters. Log every query โ€” who asked what, when, and what documents were retrieved โ€” for your audit trail.

Sensitive Document Handling

Some documents (M&A materials, salary data, personal health information) should never enter the knowledge base at all. Build a classification step in your ingestion pipeline that flags sensitive documents for exclusion. For regulated industries, see our detailed guide on Claude deployment in regulated industries and our Claude Security & Governance service for enterprise-grade controls.

Step 6: Production Deployment

The difference between a prototype and a production knowledge base is operational robustness. Here's what production-grade looks like.

API Layer Architecture

Wrap your knowledge base in a FastAPI or Node.js service with proper rate limiting, authentication middleware, and observability. Never expose the Claude API directly to the frontend. Your service layer handles auth, query preprocessing, retrieval, Claude API calls, and response formatting. This also lets you add caching โ€” if 40% of queries are for the same common questions, cache the Claude responses with a short TTL.

Observability and Quality Monitoring

Log every query, the retrieved chunks, and the Claude response. Build a simple dashboard showing: retrieval hit rate (did the system find relevant documents?), answer confidence distribution, and most common unanswered queries. Review the unanswered queries weekly โ€” they tell you exactly what knowledge gaps need filling in your document corpus. Tools like LangSmith, Arize, or a simple PostgreSQL query log work well for this.

Frontend: Claude Cowork vs Custom UI

If your team already has Claude Cowork, you can build a custom plugin that connects to your knowledge base MCP server without building a frontend at all. Cowork handles the chat UI, file uploads, and Dispatch scheduling. For organisations without Cowork, build a simple React or Next.js chat interface โ€” it only needs a text input, message history, and source citation display. See our Claude-powered chatbot tutorial for the complete frontend build.

Critical deployment step: Before going live, run 50โ€“100 test queries against the system and manually verify both the retrieved documents and the Claude answers. Identify the top 10 failure modes and tune your chunking, retrieval parameters, or system prompt to address them.

Maintenance and Continuous Improvement

A knowledge base deployed once and never maintained degrades quickly. Documents go stale, the organisation grows new teams and processes, and user needs evolve. Schedule a monthly review: update the ingestion pipeline for any new document sources, review the most common unanswered queries, and periodically re-evaluate your chunking and retrieval parameters as the corpus grows.

The teams that get the most value from Claude-powered knowledge bases treat them as living systems. They assign someone โ€” usually a senior technical writer or developer advocate โ€” to own the knowledge base health. That person curates what gets indexed, reviews audit logs for misuse or failure patterns, and champions new document sources as the company adds them. If you want to see how successful enterprises have structured this, review our Claude implementation case studies.

For help designing and deploying your knowledge base, our Claude API Integration service covers the full build: architecture, ingestion pipeline, Claude integration, access controls, and production deployment. We've shipped these systems for legal firms, financial institutions, and engineering organisations with corpora ranging from 5,000 to 500,000 documents.

CI

ClaudeImplementation Team

Claude Certified Architects with production deployments across financial services, legal, and enterprise software. About us โ†’

Get Expert Help

Build It Right the First Time

Knowledge base architecture mistakes are expensive to undo. Our Claude API Integration team has deployed these systems across dozens of enterprises. We'll get you to production faster and without the wrong-turn rebuilds.