跳到正文
视频中级

通过 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.

继续学习