Vibe Coding an Anthropic MCP Server for Diffbot using Claude Sonnet 4

The objective is simple. “Build an MCP server for Diffbot’s DQL and Enhance APIs with Python.” I type this into a brand new chat with Claude Sonnet 4.

The First Pass and File Setup

Claude generates two code snippets straight from memory. It was implicitly inferred from the setup instructions to name the python code diffbot_mcp_server.py. The other code snippet was a combination of a requirements.txt file, a pyproject.toml file, a .env file, and a README.md file. I infer that the intention was to copy/paste these snippets into separate files.

Resolving Dependency and Version Issues

Once I have all 4 files setup (sans README), I follow the usage instructions and run into my first error. There is no such thing as an [email protected]. The first release of mcp was 0.9.1, on Nov 20, 2024. The current version of mcp is 1.9.2. I choose to simply replace the mcp line in requirements.txt with mcp>=1.9.2. The other two libraries were within 0.x.x versions of current releases and pip install works! Next on the usage instructions is to export my Diffbot Token.

Project Structure Overview

File Name Description
diffbot_mcp_server.py The main Python code for the MCP server.
requirements.txt List of dependencies (mcp, etc.).
.env Environment file for the Diffbot Token.
claude_desktop_config.json Configuration for Claude for Desktop integration.

Handling Server Errors

Time to start the server. It fails with an import error. I paste the error into Claude. It runs a web search, finds something, and begins editing its code immediately. I replace all of diffbot_mcp_server.py with the new code snippet. Claude mentions using some new decorators. The new requirements.txt snippet replaces the non-existent [email protected] with mcp>=1.0.0. The new snippet maintains the import asyncio line, but removes all usage of asyncio entirely.

Testing the MCP Server

To test it, Claude churned out 2 fresh testing code snippets. Downloading these provides a debug_diffbot_server.py file and a mcp_test_client.py file. Claude says to run python debug_diffbot_server.py. It works! I proceed with the next instruction, running python mcp_test_client.py after setting my Diffbot token.

Claude for Desktop Configuration

To setup our MCP for use with Claude for Desktop, I need to setup a config file. I read the example config file and create a handwritten entry in my claude_desktop_config.json file. Claude for Desktop accepts it. It’s running, and it actually works! Claude attempted to make a tool call using enhance_url, a tool it added with our MCP server.