wllcnm
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"reddit": {
"args": [
"run",
"-i",
"--rm",
"-e",
"REDDIT_CLIENT_ID=你的client_id",
"-e",
"REDDIT_CLIENT_SECRET=你的client_secret",
"-e",
"REDDIT_USER_AGENT=你的user_agent",
"ghcr.io/nangeplus/mcp-reddit:latest"
],
"command": "docker"
}
}
}
服务介绍
MCP Reddit Server
1. Project Introduction
This is a Reddit server based on the MCP (Model Context Protocol) protocol, specifically designed for interacting with large language models like Claude. Through this service, you can have AI assistants help you browse and analyze content on Reddit.
1.1 Main Features
- Search for posts in specific subreddits
- Get detailed information and comments of posts
- Browse popular posts in subreddits
1.2 Project Structure
nangeAGICode/reddit_chat_claude/
├── .github/
│ └── workflows/
│ └── docker.yml # GitHub Actions workflow configuration
├── src/
│ ├── init.py
│ └── server.py # Core code of the MCP server
├── .gitignore # Git ignore file configuration
├── Dockerfile # Docker build file
├── LICENSE # MIT license
├── README.md # Project documentation
└── requirements.txt # Python dependency list
2. Installation and Configuration
2.1 Prerequisites
- Docker (required)
- Python 3.12+ (for local development)
- Reddit API credentials (required)
2.2 Obtaining Reddit API Credentials
- Visit https://www.reddit.com/prefs/apps
- Click "create another app..."
- Select "script"
- Fill in the necessary information
- Obtain
client_idandclient_secret
2.3 Environment Variable Configuration
You need to set the following environment variables:
bash
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USER_AGENT=your_user_agent
2.4 Docker Installation
For Mac users:
-
Visit the Docker official website: https://www.docker.com/products/docker-desktop
-
Click "Download for Mac"
-
Choose the version corresponding to your Mac chip (Apple Silicon or Intel)
-
Download and install the .dmg file
-
Verify the installation:
bash
Check Docker version
docker --version
Run a test container
docker run hello-world
- Ensure that the Docker service is running:
bash
Check Docker service status
docker ps
3. Usage
3.1 Using in Claude Desktop Client
Add the following configuration to your claude_desktop_config.json:
json
{
"mcpServers": {
"reddit": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "REDDIT_CLIENT_ID=your_client_id",
"-e", "REDDIT_CLIENT_SECRET=your_client_secret",
"-e", "REDDIT_USER_AGENT=your_user_agent",
"ghcr.io/nangeplus/mcp-reddit:latest"
]
}
}
}
3.2 Available Tools
-
search_subreddit: Search for posts in a specific subreddit
- Parameters:
subreddit: Subreddit namequery: Search keywordlimit: Maximum number of results to return (default: 5)
- Parameters:
-
get_post_details: Get detailed information about a specific post
- Parameters:
post_id: Reddit post IDcomment_limit: Maximum number of comments to fetch (default: 10)
- Parameters:
-
get_subreddit_hot: Get popular posts in a subreddit
- Parameters:
subreddit: Subreddit namelimit: Maximum number of posts to return (default: 5)
- Parameters:
3.3 Usage Examples
In Claude, you can use the tools as follows:
json
{
"tool": "get_subreddit_hot",
"arguments": {
"subreddit": "Python",
"limit": 3
}
}
Example Conversation:
User: Help me check the top 3 hottest posts in the Python subreddit.
Claude: Sure, I'll help you check. I will use the get_subreddit_hot tool:
json
{
"tool": "get_subreddit_hot",
"arguments": {
"subreddit": "Python",
"limit": 3
}
}
[Claude will return the post information]
User: Help me check the details and comments of the first post.
Claude: I will use the get_post_details tool:
json
{
"tool": "get_post_details",
"arguments": {
"post_id": "returned_post_id"
}
}
4. Local Development
4.1 Clone the Repository
bash
git clone https://github.com/nangeplus/mcp-reddit.git
cd mcp-reddit
4.2 Install Dependencies
bash
pip install -r requirements.txt
4.3 Run the Server
bash
python src/server.py
4.4 Docker Build
bash
docker build -t mcp-reddit .
docker run -i --rm
-e REDDIT_CLIENT_ID=your_client_id
-e REDDIT_CLIENT_SECRET=your_client_secret
-e REDDIT_USER_AGENT=your_user_agent
mcp-reddit## 5. Precautions
-
Security
- Please keep your Reddit API credentials secure.
- Do not share your configuration files in public places.
- It is recommended to use environment variables instead of hardcoding the credentials.
-
Usage Limitations
- The Reddit API has call frequency limitations.
- The default limit for returned comments is 10.
- The default limit for search results is 5.
-
Troubleshooting
- Check if the API credentials are correct.
- Ensure that the network connection is stable.
- Review the log output for detailed error information.
6. Contribution Guidelines
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
7. License
This project is licensed under the MIT License - see the LICENSE file for details