Skip to content

Thanks to pykv ! ! #247

@whillhill

Description

@whillhill

A huge thank you to the py-key-value author!

First and foremost, I want to express my most sincere and heartfelt gratitude to the author of py-key-value! Your project has perfectly solved the challenges I was facing with data source pluggability and sharing/migration in my development process.

I'm currently developing a project called mcpstore, and recently I've been struggling with exactly how to handle data source migration and performance optimization for the store (which is essentially the client component).

The arrival of py-key-value came at just the right time and solved these problems perfectly! It allowed me to easily implement seamless switching between in-memory caching and Redis caching.

I'm really excited to share with you what I've accomplished after integrating your package - this is something I thought would take me a very long time to implement!

First, I can now synchronize and persist my cache data with Redis based on an mcp.json file:

from mcpstore import MCPStore, RedisConfig

# Method 1: JSON configuration + Redis cache
redis_cfg = RedisConfig(host="localhost", port=6379, db=0)
store = MCPStore.setup_store(
    mcpjson_path="/path/to/mcp.json",
    cache=redis_cfg
)

Thanks to pykv, my mcpstore can now share Redis cache across any host and immediately access the MCP data space.

# Method 2: Pure Redis mode (no local files needed)
store = MCPStore.setup_store(cache=redis_cfg)

This was my previous standard approach, limited to memory only. Now even the memory backend uses pykv, enabling true hot-plugging capabilities!

# Method 3: Default memory mode
store = MCPStore.setup_store(mcpjson_path="/path/to/mcp.json")

Dynamic cache backend switching at runtime with automatic data migration:

# Memory → Redis
redis_cfg = RedisConfig(host="localhost", port=6379)
store.for_store().switch_cache(redis_cfg)

# Redis → Memory
store.for_store().switch_cache("memory")
┌─────────────────────────────────────────────────────────────┐
│                        MCPStore                               │
│                                                               │
│  ┌───────────────────────────────────────────────────────┐   │
│  │           setup_store(cache=CacheConfig)            │   │
│  └─────────────────┬─────────────────────────────────────┘   │
│                    │                                         │
│                    ▼                                         │
│  ┌───────────────────────────────────────────────────────┐   │
│  │          Cache Configuration Layer                   │   │
│  │  ┌──────────────┐      ┌──────────────┐           │   │
│  │  │ MemoryConfig │      │ RedisConfig  │           │   │
│  │  └──────┬───────┘      └──────┬───────┘           │   │
│  └─────────┼──────────────────────┼───────────────────┘   │
│            │                      │                       │
│            ▼                      ▼                       │
│  ┌─────────────────┐    ┌─────────────────────────┐         │
│  │  MemoryStore    │    │   RedisStore            │         │
│  │  (py-key-value) │    │   (py-key-value)        │         │
│  └─────────────────┘    └──────────┬──────────────┘         │
│                                     │                       │
│                                     ▼                       │
│                          ┌──────────────────────┐           │
│                          │  redis.asyncio.Redis │           │
│                          │  (Official Client)   │           │
│                          └──────────────────────┘           │
└─────────────────────────────────────────────────────────────┘

I'm still a student, and thanks to my internship where I got exposed to MCP and incubated this project. With the help of AI, I've been stumbling along, gradually improving this project and implementing my ideas step by step. My understanding of open source contributions used to be just something I read about, but this time I've truly felt the power of open source firsthand. I can't wait to share this with you and express my sincere gratitude for your contribution - your project has genuinely helped me immensely. Thank you so much!

My project link: https://github.com/whillhill/mcpstore

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions