本文へスキップ
動画中級

MCP サーバー経由で Windsurf から Cloudflare D1 データベースと対話する

Cloudflare のデベロッパーアドボケイト Lizzie が、MCP サーバーを使って Windsurf から Cloudflare D1 データベースを直接クエリする連携を、Goodreads の書籍データベースを例に紹介します。

著者
Cloudflare Developers
公開日
2025年5月9日
再生時間
0:03:36
YouTube で見る

この紹介文は現在英語版のみです。

In this insightful tutorial, Cloudflare developer advocate Lizzie demonstrates a powerful integration that enables you to query your Cloudflare D1 database directly through natural language in Windsurf using a Model Completion Provider (MCP) server. The demonstration uses a personal Goodreads book database to showcase this practical application.

repo in remote-mcp-server-authless-talk-to-db

Demo Overview

The video begins with a compelling demonstration where Lizzie enters a simple query for “all of the Princess Diaries books” in Windsurf. The system leverages the MCP server’s intelligent search capabilities to process this natural language request, execute the appropriate database query, and return detailed results including book titles, authors, and personal ratings.

Technical Implementation

Setting Up the MCP Server

Lizzie highlights how remarkably straightforward it is to deploy remote Cloudflare MCP servers using the official Cloudflare documentation. The key component of this implementation is the custom ‘search books’ tool added to the MCP server configuration. This specialized tool:

  • Accepts natural language user queries
  • Supports advanced query parameters (sorting by rating, limiting results)
  • Enables filtering by ‘bookshelf’ categories (e.g., ‘read’, ‘currently reading’, ‘to read’)

How the Search Tool Works

The search books tool uses intelligent query parsing to:

  1. Analyze the natural language search string to determine query intent
  2. Construct and execute appropriate SQL queries against the Goodreads DB (Cloudflare D1 database)
  3. Format the results in a structured way
  4. Pass the formatted data to the Workers AI LLM (specifically LLaMA 3.3) for natural language response generation

Configuration Details

The tutorial covers essential configuration steps including:

  • Setting up Windsurf connection parameters to your MCP server
  • Configuring the MCP config.json file with proper endpoints and tool definitions
  • Setting up the necessary Cloudflare Worker bindings for both the D1 database and Workers AI

Database Structure

Lizzie provides a glimpse into the Goodreads database structure, showing essential fields such as:

  • Book ID
  • Title
  • Author
  • Publication details
  • Personal ratings
  • Shelf categorization

Testing and Accessibility

An additional benefit highlighted in the video is that the search books function on the MCP server can be independently tested through the Cloudflare Workers AI LLM Playground, providing a convenient development experience.

Conclusion

The video concludes with an encouraging call to action for viewers to implement their own solution to chat with their D1 databases through Windsurf using Cloudflare MCP servers. This powerful combination of Cloudflare MCP, Cloudflare D1, and Windsurf unlocks new possibilities for natural language interaction with your data.

さらに学ぶ