DEV Community

KevinTen
KevinTen

Posted on

MCP-Optimized Knowledge Bases: Why Simple Beats Complex When AI Does the Thinking

MCP-Optimized Knowledge Bases: Why Simple Beats Complex When AI Does the Thinking

Honestly, I didn't see this coming.

Six months ago, I would have told you my 1,800-hour personal knowledge management project was a spectacular failure. I'd built everything from semantic search to AI recommendation engines, spent thousands of dollars on cloud infrastructure, and wrote over 2,000 lines of Java code that nobody used. The stats were brutal:

  • 1,847 hours of development
  • 2,847 saved articles
  • 84 actual uses in three years
  • 2.9% knowledge utilization
  • -99.4% ROI

I was this close to hitting "delete" on the whole repository. Then something interesting happened: Model Context Protocol (MCP) changed everything.

If you've been living under a rock like I was, MCP is the new standard that lets AI clients discover and call tools from external servers. It's like REST but for AI agents. Suddenly, my "failed" knowledge system wasn't a failed product anymore—it was an MCP server that any AI could use. And the punchline? The simple version I ended up with after years of over-engineering is exactly what works best in the MCP world.

Let me walk you through what I learned.

The Old Way: AI Inside Your Knowledge System

Here's what I built originally. Like every knowledge management nerd, I believed the AI had to live inside the system. You need semantic understanding! Vector embeddings! Recommendation algorithms! All that good stuff.

Here's what that looked like in Java:

// This is what 2000 lines of over-engineering looks like
@Service
public class ComplexKnowledgeService {
    private final EmbeddingService embeddingService;
    private final VectorDatabase vectorDatabase;
    private final RecommendationEngine recommendationEngine;
    private final SemanticSearch semanticSearch;

    public List<KnowledgeItem> search(String query) {
        // 1. Embed the query
        Embedding queryEmbedding = embeddingService.embed(query);

        // 2. Find similar vectors
        List<VectorMatch> matches = vectorDatabase.search(queryEmbedding, 10);

        // 3. Rerank with semantic analysis
        List<KnowledgeItem> items = semanticSearch.rerank(matches, query);

        // 4. Apply recommendation filters
        return recommendationEngine.filterByUserBehavior(items);
    }
}
Enter fullscreen mode Exit fullscreen mode

Looks impressive, right? It was impressive. It was also completely unnecessary.

The problem? I was trying to do the AI's job for it. I spent months optimizing semantic search when I could have just let GPT-4o or Claude do the understanding. All that complexity just made my system slower, more expensive, and harder to maintain. And the kicker—my "AI-enhanced" search was worse than just dumping the relevant text into a prompt and letting the actual AI do the work.

So here I am, three years later, looking at this mess of code, thinking "What's the point?" Then I read about MCP, and everything clicked.

The MCP Insight: AI Is Already Smart—Just Give It the Data

The epiphany hit me like a ton of bricks: In the MCP world, the AI doesn't live in your knowledge system. Your knowledge system lives in the AI's world.

Think about it. When you're using Claude Desktop or Cursor or any MCP-compatible client, the AI is already the smart one. It can understand context, it can connect dots, it can synthesize information. Your knowledge system doesn't need to do any of that. It just needs to do one thing well: find the relevant chunks of text and hand them to the AI.

That's it. That's the whole insight.

So I threw away 1,950 lines of code and ended up with this:

@RestController
@RequestMapping("/mcp")
public class MCPServerController {

    private final SimpleKnowledgeService knowledgeService;

    public MCPServerController(SimpleKnowledgeService knowledgeService) {
        this.knowledgeService = knowledgeService;
    }

    // MCP requires tools/list endpoint
    @GetMapping("/tools/list")
    public McpResponse listTools() {
        return McpResponse.success(List.of(
            ToolDefinition.builder()
                .name("search_knowledge")
                .description("Search my personal knowledge base for articles and notes")
                .parameter(ParameterDefinition.builder()
                    .name("query")
                    .type("string")
                    .description("What to search for")
                    .required(true)
                    .build())
                .build()
        ));
    }

    // MCP requires tools/call endpoint
    @PostMapping("/tools/call")
    public McpResponse callTool(@RequestBody ToolCallRequest request) {
        if (!"search_knowledge".equals(request.getName())) {
            return McpResponse.error("Unknown tool: " + request.getName());
        }

        String query = request.getParameter("query", String.class);
        List<KnowledgeItem> results = knowledgeService.simpleSearch(query, 5);

        // Return plain text results—AI does the rest
        return McpResponse.success(results.stream()
            .map(item -> new KnowledgeResult(
                item.getTitle(),
                item.getContent().substring(0, Math.min(item.getContent().length(), 2000)),
                item.getTags(),
                item.getCreatedAt()
            ))
            .toList());
    }
}
Enter fullscreen mode Exit fullscreen mode

And the search service? It's embarrassingly simple:

@Service
public class SimpleKnowledgeService {

    private final List<KnowledgeItem> allItems;

    public SimpleKnowledgeService(KnowledgeRepository repository) {
        // Load everything into memory on startup
        this.allItems = repository.findAll();
    }

    public List<KnowledgeItem> simpleSearch(String query, int limit) {
        String lowerQuery = query.toLowerCase();

        // Yes, this is really it. 20 lines instead of 2000.
        return allItems.stream()
            .filter(item -> 
                item.getTitle().toLowerCase().contains(lowerQuery) ||
                item.getContent().toLowerCase().contains(lowerQuery) ||
                item.getTags().stream().anyMatch(t -> t.toLowerCase().contains(lowerQuery)))
            .limit(limit)
            .toList();
    }
}
Enter fullscreen mode Exit fullscreen mode

That's the whole MCP server. 70 lines of code total. Down from 2,000.

I kid you not—it works better than the original complex version. Like, way better.

Why This Works (The Counterintuitive Part)

Let me break down why simple beats complex in the MCP architecture:

1. AI Does the Heavy Lifting Now

Before, I was trying to do semantic understanding in my knowledge system. I'd compute embeddings, find similar documents, rerank results—it was a whole thing. But with MCP, here's what actually happens:

  1. User asks Claude: "What did I write about MCP optimization?"
  2. Claude calls my search_knowledge tool with the query "MCP optimization"
  3. My simple search returns the top 5 articles that contain the words "MCP" or "optimization"
  4. Claude reads the articles, understands the context, connects the dots, and answers the question

That's it. The AI does the understanding. I just do the retrieval. Why was I trying to do the AI's job this whole time?

2. Standard Protocol Means Universal Compatibility

Before, if I wanted to use my knowledge system with a new AI client, I had to build a custom integration. Each client had different APIs, different authentication schemes, different response formats. It was a maintenance nightmare.

With MCP? I implement the protocol once, and every MCP-compatible client can use it. That's the magic of standards. Claude Desktop, Cursor, OpenAI GPTs, whatever comes next—if it speaks MCP, it works with my server.

3. Privacy-Friendly by Design

Here's another win I didn't expect: my knowledge stays private. Before, if I wanted AI to use my knowledge, I had to upload all my notes to OpenAI or Anthropic or whoever. That always made me uncomfortable—some of these are personal notes, project ideas, half-baked thoughts I don't really want to share with anyone.

With MCP:

  • All my data stays on my server
  • Only the specific results for the current query get sent to the AI
  • The AI never sees my entire knowledge base
  • I control who can access it

It's a beautiful middle ground between having AI access your knowledge and keeping your data private.

4. Less Code = Less Maintenance = More Reliable

I don't need to maintain vector databases anymore. I don't need to pay for embedding API calls. I don't need to retrain models when my knowledge grows. I just store markdown files in PostgreSQL, load them into memory on startup, and do simple string matching.

My hosting costs went from $45/month to $5/month. That's not nothing when you're losing $112k on the project already.

The Pros & Cons (I Promise I'm Not Biased)

Okay, let's be honest—this approach isn't perfect. Nothing is. Let me give you the real deal:

✅ Pros That Surprised Me

  1. It just works – No dependency on external ML APIs, no complex infrastructure, no downtime when OpenAI is having issues. If my server is up, it works. That's it.

  2. Surprisingly fast – On my 4GB VPS, with 2,800 articles, a search takes 5-10ms. That's nothing. Even if I had 28,000 articles, it would still be faster than waiting for an LLM to respond.

  3. AI gets the full context – Because we're sending the actual content, not just links or summaries, the AI can actually read what I wrote. It can connect ideas across multiple articles. It can quote me correctly. It's way more useful than just "here are some links, go read them yourself."

  4. Iteration is cheap – Want to add a new tool? Add another endpoint. Want to change how search works? Tweak 10 lines of code. No big redeployment, no schema migrations, nothing.

  5. Resurrected a dead project – This is the big one. My 1,800-hour "failure" is actually useful again. Before, I would open it once every couple of months when I was writing an article. Now, Claude automatically uses it when we're discussing projects I've worked on. It's like having a second brain that actually remembers things.

❌ Cons You Need to Know About

  1. It's brute-force – Simple string matching isn't as smart as semantic search. If I write about "model context protocols" and search for "MCP," it doesn't find it unless I've tagged it properly. Is this a problem? Honestly, not that often. When it matters, I just search again with different terms.

  2. Memory usage grows with your knowledge – If you have 100,000 articles, loading everything into memory won't work. But for personal knowledge bases? 2,000-10,000 articles is nothing for modern servers. You'd be surprised how much text fits in 1GB of RAM.

  3. MCP is still young – The ecosystem is developing. Not every AI client supports it yet. The protocol itself might change. If you need something rock-solid for production, maybe wait another year. But for personal projects? It's perfectly usable right now.

  4. You still need to host it – Your MCP server needs to be publicly accessible for cloud clients to use it. If you want it working locally only, that's fine for local clients like Claude Desktop, but if you want it available everywhere, you need hosting. I use a cheap VPS and it's fine, but that's one more thing to maintain.

  5. Context window limits still apply – You can only send so much text to the AI in one prompt. If your search returns 5 long articles, you might hit context limits. I solve this by truncating longer articles to 2000 characters in the API response, which works fine for most cases. If the AI needs more, it can ask for the full article.

What I Learned the Hard Way

So after three years of over-engineering and one month of MCP experimentation, here's what I've concluded:

In the age of AI agents, your knowledge system doesn't need to be smart. It just needs to be findable.

The AI is already smart. That's its job. Your job is to give it the right information at the right time. That's it. You don't need to outsmart the AI. You just need to connect the AI to your data.

I spent three years thinking I needed to build an AI-powered knowledge system. Turns out, I just needed to build a knowledge system that AI can power. Big difference.

Another thing I learned: Simple systems age better than complex ones. My 2000-line semantic search monstrosity is already obsolete. My 70-line MCP server will probably still work in five years because it just does one simple thing and uses a standard protocol.

Try It Yourself

If you have an existing knowledge base that's collecting dust, I encourage you to try this approach. You don't need to rewrite everything. Just add an MCP endpoint that exposes your existing search.

Here's the minimal checklist:

  1. Implement GET /mcp/tools/list with your tool definitions
  2. Implement POST /mcp/tools/call that executes the tool
  3. Add authentication (you don't want just anyone accessing your knowledge)
  4. Configure your MCP client to point to your server
  5. That's it. Start using it.

My entire implementation is open source if you want to peek: https://github.com/kevinten10/Papers

It's still a work in progress, but that's kind of the point—keep it simple, iterate as you go.

Your Turn

I'm still pretty new to the whole MCP game. This approach has worked amazingly well for my personal knowledge base, but I know there are probably smarter ways to do it.

Have you tried integrating MCP with your own knowledge system? Are you still over-engineering your search like I was? Did you find a better middle ground between simple brute-force and full semantic search?

Drop a comment below and tell me about your experience. I'm genuinely curious to see what other people are building in this space.

And if you try this simple approach, let me know how it works for you. Maybe we're all overthinking this knowledge management thing anyway.

Top comments (0)