Cover image
model_context_protocol_examples
Public

model_context_protocol_examples

Try Now
2025-04-02

在模型上下文协议中构建服务器测试的一些示例。 mộtsốvídụsửdụngmcp

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

SQLite Database Demo

This project demonstrates the usage of SQLite database with async support in a FastMCP application.

Features

  • Async SQLite database operations using aiosqlite
  • Automatic database initialization with sample data
  • Type-safe database context management
  • Proper connection lifecycle handling

Prerequisites

  • Python 3.7+
  • pip (Python package installer)

Installation

  1. Clone this repository
  2. Install the required dependencies:
pip install -r requirements.txt

Project Structure

  • server.py: Main FastMCP server implementation with database context management
  • database.py: SQLite database implementation with async support
  • demo.db: SQLite database file (created automatically on first run)

Database Schema

The demo database includes a users table with the following structure:

CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE NOT NULL
)

Sample data is automatically inserted on first run:

Usage

  1. Start the server:
python server.py
  1. The database will be automatically initialized with the sample data on first run.

  2. Use the query_db tool to retrieve data from the database.

Database Operations

The Database class provides the following methods:

  • connect(): Creates a new database connection and initializes the schema
  • query(): Executes a sample query to retrieve all users
  • disconnect(): Closes the database connection

Customization

To modify the database schema or add new tables:

  1. Edit the _init_db() method in database.py
  2. Add new methods to Database class for custom queries
  3. Update the query_db tool in server.py to use new methods

Error Handling

The database implementation includes:

  • Automatic connection cleanup on server shutdown
  • Proper async context management
  • Type safety with Python type hints

Dependencies

  • aiosqlite>=0.19.0: Async SQLite database driver
  • pandas>=2.0.0: Data manipulation library
  • numpy>=1.24.0: Numerical computing library

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • HiveNexus
  • 一个适用于中小型团队的AI聊天机器人,支持DeepSeek,Open AI,Claude和Gemini等车型。 专为中小团队设计的ai聊天应用,支持deepSeek,打开ai,claude,双子座等模型。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

    Reviews

    4 (1)
    Avatar
    user_Qacl6PFJ
    2025-04-16

    Model_context_protocol_examples is an excellent resource created by anhnx000. The repository on GitHub provides clear examples and thorough explanations. It's incredibly useful for anyone looking to understand and implement model context protocols efficiently. Highly recommended for developers seeking to enhance their knowledge in this area.