Metadata-Version: 2.4
Name: mcp-redis-airnet
Version: 0.0.1
Summary: Use for AinrNet Redis,add 'info' tool
Author-email: mi_zy <mi_zy@sina.com>
Requires-Python: >=3.12
Requires-Dist: mcp[cli]>=1.4.1
Requires-Dist: pydantic-settings>=2.8.1
Requires-Dist: redis>=5.0.2
Description-Content-Type: text/markdown

# mcp-redis-airnet: A Redis MCP Server for AirNet 
# purpose：base mcp-server-redis add tools get_info
# Chagne-Tip:
version = "0.0.1"
  1、__main__.py & __init__.py invalid syntax：from mcp-redis-airnet import main Revise to from mcp_redis_airnet import main
  2、add tools `get_info`: Get Redis server information

> The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.

This repository is an example of how to create an MCP server for managing Redis data.

[![PyPI version](https://badge.fury.io/py/mcp-server-redis.svg)](https://pypi.org/project/mcp-server-redis/)

## Overview

A Model Context Protocol server for interacting with Redis. It provides tools for setting, retrieving, listing, and deleting keys in Redis.

## Components

### Tools

The server implements the following tools:

- `set_value`: Set a specified key to a given value
  - Takes a `key` (string) and a `value` (string)
  - Returns a confirmation message upon success

- `get_value`: Retrieve the value of a specified key
  - Takes a `key` (string)
  - Returns the value as a string, or `None` if the key does not exist

- `list_keys`: List Redis keys matching a given pattern
  - Takes a `pattern` (default: "*")
  - Returns a list of matching keys

- `delete_key`: Delete a specified key
  - Takes a `key` (string)
  - Returns the number of keys deleted (0 or 1)

- `get_info`: Get Redis server information
  - Returns Redis server information

## Configuration

The server connects to Redis using the following environment variables (all are required):

- `REDIS_HOST`: Redis host  
- `REDIS_PORT`: Redis port  
- `REDIS_DB`: Redis database number  
- `REDIS_PASSWORD`: Redis password  

If any of these variables are missing, the server will raise an error during startup. Make sure to set each of these before running the server.

## Quickstart

#### Claude Desktop

On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`  
On Windows: `%APPDATA%/Claude/claude_desktop_config.json`

```json
{
  "redis": {
    "command": "uvx",
    "args": [
      "mcp-redis-airnet"
    ]
  }
}
```
#### Trae Desktop
```json
{
  "mcpServers": {
    "redis-airnet": {
      "command": "uvx",
      "args": [
        "--from",
        "mcp-redis-airnet==0.0.1",
        "--refresh-package",
        "mcp-redis-airnet",
        "mcp-redis-airnet"
      ],
      "env": {
        "REDIS_HOST": "192.168.31.158",
        "REDIS_PORT": "6379",
        "REDIS_DB": "0",
        "REDIS_PASSWORD": "cdatc"
      }
    }
  }
}
```
本地调试运行
```json
{
  "mcpServers": {
    "redis-add": {
      "command": "uv",
      "args": [
        "--directory",
        "E:\\技术支持室\\Trae\\redis-AirNet\\src\\mcp_redis_airnet\\",
        "run",
        "server.py"
      ],
      "env": {
        "REDIS_HOST": "192.168.31.158",
        "REDIS_PORT": "6379",
        "REDIS_DB": "0",
        "REDIS_PASSWORD": "cdatc"
      }
    }
  }
}
```

## Development

### Building and Publishing

To prepare the package for distribution:
python -m venv .venv
.venv\Scripts\activate
python -m ensurepip --upgrade
python -m pip install --upgrade pip
pip install twine
twine check dist/*
	Checking dist\mcp_redis_airnet-1.0.1-py3-none-any.whl: PASSED
	Checking dist\mcp_redis_airnet-1.0.1.tar.gz: PASSED
  
1. Sync dependencies and update lockfile:
```bash
uv sync
```

2. Build package distributions:
```bash
uv build
```

This will create source and wheel distributions in the `dist/` directory.

3. Publish to PyPI:
```bash
uv publish
uv publish --token pypi-Ag...
```

Note: You'll need to set PyPI credentials via environment variables or command flags:
- Token: `--token` or `UV_PUBLISH_TOKEN`
- Or username/password: `--username`/`UV_PUBLISH_USERNAME` and `--password`/`UV_PUBLISH_PASSWORD` （PyPI已经移除了对用户名/密码认证的支持）

### Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging
experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).

You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:

```bash
npx @modelcontextprotocol/inspector uv --directory $(PWD) run mcp-redis-airnet
```

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.