aniketwattamwar/reddit-mcp
If you are the rightful owner of reddit-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project provides a FastMCP-based server for interacting with Reddit's API, offering tools and resources for fetching subreddit information, user details, and performing searches.
Reddit MCP Server
This project provides a FastMCP-based server for interacting with Reddit's API. It includes tools and resources for fetching subreddit information, user details, and performing searches.
Features
- Fetch subreddit details dynamically.
- Retrieve user information.
- Search Reddit posts based on queries.
- Access popular subreddits and Reddit API status.
Prerequisites
- Python: Ensure Python 3.11 is installed.
- Dependencies: Install required Python packages using
pip
. - Reddit API Access: Obtain a Reddit API access token.
Installation
-
Clone the repository:
git clone https://github.com/your-username/reddit-mcp.git cd reddit-mcp
-
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment:
- Windows:
.venv\Scripts\activate
- Linux/Mac:
source .venv/bin/activate
- Windows:
-
Install dependencies:
pip install -r requirements.txt
Running the MCP Server
-
Start the MCP server:
python mcp_server.py
mcp run mcp_server.py
mcp dev mcp_server.py
opens inspector and you can check how your mcp server is working
- The server will initialize and expose tools and resources for Reddit API interaction.
Obtaining Reddit Access Token
To interact with Reddit's API, you need an access token:
-
Create a Reddit App:
- Go to Reddit Apps.
- Click "Create App" or "Create Another App".
- Fill in the required details:
- App type: Script.
- Name: Your app name.
- Redirect URI:
http://localhost
. - Permissions: Select appropriate scopes.
-
Generate Access Token:
- Use the following Python script to generate a token:
import requests from requests.auth import HTTPBasicAuth client_id = "your_client_id" client_secret = "your_client_secret" username = "your_reddit_username" password = "your_reddit_password" auth = HTTPBasicAuth(client_id, client_secret) data = { "grant_type": "password", "username": username, "password": password } headers = {"User-Agent": "YourAppName/0.1"} response = requests.post("https://www.reddit.com/api/v1/access_token", auth=auth, data=data, headers=headers) print(response.json())
- Replace
your_client_id
,your_client_secret
,your_reddit_username
, andyour_reddit_password
with your credentials. - The script will return an access token.
OR - Use Postman
- Use the following Python script to generate a token:
-
Set the Access Token:
- Update the
Authorization
header inmcp_server.py
:client.headers["Authorization"] = f"Bearer {your_access_token}"
- Update the
Contributing
We welcome contributions to improve the Reddit MCP Server. Follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add feature description"
- Push your branch:
git push origin feature-name
- Create a pull request.
License
This project is licensed under the MIT License. See the LICENSE
file for details.
Contact
For questions or support, open an issue in the repository.