OpenAI MCP Client logo

OpenAI MCP Client

by devmadni

This is a Node.js command-line application that integrates with GitHub via the Model Context Protocol (MCP) server and OpenAI's API. It allows users to perform GitHub operations and query OpenAI for GitHub-related information using context from an MCP server.

View on GitHub

Last updated: N/A

OpenAI MCP Client for GitHub This is a Node.js command-line application that integrates with GitHub via the Model Context Protocol (MCP) server and OpenAI's API. It allows users to perform GitHub operations (e.g., creating repositories, listing repositories) and query OpenAI for GitHub-related information using context from an MCP server. Features

GitHub Operations: Create new repositories. List all repositories. List GitHub API endpoints.

OpenAI Integration: Query OpenAI with GitHub context from an MCP server for detailed answers (e.g., "How to create a pull request").

Interactive CLI: Simple command-line interface for entering commands.

Secure Configuration: Uses environment variables for API keys.

Prerequisites

Node.js: Version 14 or higher (recommended: latest LTS). npm: Comes with Node.js. GitHub Personal Access Token: Required for GitHub API access. OpenAI API Key: Required for OpenAI queries. Git: For version control and pushing to GitHub.

Installation

Clone the Repository: git clone https://github.com/[your-username]/tessst.git cd tessst

Install Dependencies: npm install

This installs axios and dotenv (added below).

Set Up Environment Variables:

Create a .env file in the project root:touch .env

Add your API keys:OPENAI_API_KEY=your_openai_api_key GITHUB_PERSONAL_ACCESS_TOKEN=your_github_personal_access_token

Note: Never commit .env to GitHub. It’s ignored by .gitignore.

Install MCP Server:

The script uses @modelcontextprotocol/server-github. It’s installed on-demand via npx, so no additional setup is needed.

Usage

Run the Application: node openai-mcp-client.js

This starts the interactive CLI.

Available Commands:

Create a new repository:create new repo named my-repo

List all repositories:list all repositories

List GitHub API endpoints:list github api

Query OpenAI:how to create a pull request

Exit:exit

Example Interaction:

create new repo named test-repo Successfully created new repository: https://github.com/[your-username]/test-repo list all repositories Your repositories:

  • tessst: Repository created via MCP client on 2025-05-03 (https://github.com/[your-username]/tessst)
  • test-repo: Repository created via MCP client on 2025-05-03 (https://github.com/[your-username]/test-repo)

how to create a pull request OpenAI's response: To create a pull request on GitHub:

  1. Push your changes to a branch...

Project Structure

openai-mcp-client.js: Main script with CLI and GitHub/OpenAI logic. .gitignore: Ignores node_modules/, .env, logs, and system files. .env: Stores API keys (not tracked by Git). package.json: Defines dependencies and scripts.

Dependencies

axios: For HTTP requests to GitHub and OpenAI APIs. dotenv: For loading environment variables from .env.

To update package.json with dotenv: npm install dotenv

Security Notes

API Keys: Store OPENAI_API_KEY and GITHUB_PERSONAL_ACCESS_TOKEN in .env, not in the code. GitHub Token: Generate a token at https://github.com/settings/tokens with repo scope. OpenAI Key: Obtain from https://platform.openai.com/account/api-keys.

Troubleshooting

"Failed to start GitHub MCP server": Ensure GITHUB_PERSONAL_ACCESS_TOKEN is valid and has repo scope. Check internet connectivity.

"Error querying OpenAI": Verify OPENAI_API_KEY is correct.

node_modules in Git: Ensure .gitignore includes node_modules/ and run:git rm -r --cached node_modules git commit -m "Remove node_modules"

Command not recognized: Use exact phrasing (e.g., "create new repo named my-repo") or check the script’s handleGitHubOperation function.

Contributing

Fork the repository. Create a feature branch (git checkout -b feature/your-feature). Commit changes (git commit -m "Add your feature"). Push to the branch (git push origin feature/your-feature). Open a pull request.

License MIT License. See LICENSE for details. Contact For issues or suggestions, open an issue on GitHub or contact [your-username].