github-MCP-practice
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"github": {
"args": [
"-m",
"mcp_github.server"
],
"command": "python",
"cwd": "/Users/hyunwoo/Desktop//20250904_githubMCP",
"env": {
"PYTHONPATH": "/Users/hyunwoo/Desktop//20250904_githubMCP",
"PYTHUB_TOKEN": "your_github_token_here"
}
}
}
}
服务介绍
MCP GitHub + MCP Client
GitHub MCP Server MCP Client (FastAPI + LangGraph) .
mcp_github/ # GitHub MCP Server (fastMCP )
mcp_client/ # MCP Client (FastAPI + LangGraph)
MCP GitHub Server
GitHub MCP server built with fastMCP.
#
source venv/bin/activate
#
pip install -e .
GitHub API Personal Access Token :
- GitHub Settings > Tokens
- :
repo,user - :
# .env ( )
echo "GITHUB_TOKEN=your_token_here" > .env
#
export GITHUB_TOKEN=your_token_here
#
source venv/bin/activate
# MCP
python -m mcp_github.server
Cursor
Cursor MCP :
{
"mcpServers": {
"github": {
"command": "python",
"args": ["-m", "mcp_github.server"],
"cwd": "/Users/hyunwoo/Desktop//20250904_githubMCP",
"env": {
"PYTHUB_TOKEN": "your_github_token_here",
"PYTHONPATH": "/Users/hyunwoo/Desktop//20250904_githubMCP"
}
}
}
}
(Read Tools)
health
{
"status": "ok"
}
getRepo
GitHub
{
"owner": "J-nowcow",
"repo": "github-MCP-practice"
}
listPullRequests
Pull Request
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"state": "open"
}
getPRDiff
Pull Request diff
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"number": 1
}
getFile
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"path": "README.md",
"ref": "main"
}
(Write Tools)
createOrUpdateFile
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"path": "new_file.txt",
"content": "Hello, World!",
"message": "Add new file",
"branch": "main",
"committer_name": "Your Name",
"committer_email": "your.email@example.com"
}
deleteFile
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"path": "file_to_delete.txt",
"message": "Delete file",
"branch": "main"
}
createBranch
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"new_branch": "feature-branch",
"base_branch": "main"
}
createCommitWithMultipleFiles
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"files": [
{
"path": "file1.txt",
"content": "Content 1",
"operation": "create"
},
{
"path": "file2.txt",
"content": "Updated content",
"operation": "update"
}
],
"message": "Multiple file changes",
"branch": "main"
}
getRepositoryStatus
{
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"ref": "main"
}
- :
{
"tool": "createOrUpdateFile",
"arguments": {
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"path": "docs/new_feature.md",
"content": "# New Feature\n\nThis is a new feature documentation.",
"message": "Add new feature documentation"
}
}
- :
{
"tool": "createOrUpdateFile",
"arguments": {
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"path": "README.md",
"content": "# Updated README\n\nUpdated content here.",
"message": "Update README"
}
}
- :
{
"tool": "createBranch",
"arguments": {
"owner": "J-nowcow",
"repo": "github-MCP-practice",
"new_branch": "feature/new-ui",
"base_branch": "main"
}
}
MCP Client (FastAPI + LangGraph)
Azure OpenAI + GitHub MCP Server MCP Client(FastAPI + LangGraph) .
REST API(/chat) :
- MCP Server(GitHub)
- LangGraph ReAct Agent Azure OpenAI
- MCP Server
- **LangGraph **
FastAPI LangGraph Agent MCP Server GitHub
/chat ReAct Workflow Tools Execution
1.
#
python -m venv venv
#
source venv/bin/activate # macOS/Linux
#
venv\Scripts\activate # Windows
2.
pip install -r requirements.txt
3.
.env :
# MCP Server
MCP_SERVER_URL=http://localhost:3000
# Azure OpenAI
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_API_KEY=your_api_key_here
AZURE_OPENAI_DEPLOYMENT=gpt-4o
AZURE_OPENAI_API_VERSION=2025-01-01-preview
OPENAI_TEMPERATURE=0.1
# HTTP
HTTP_TIMEOUT_SEC=30
4.
#
uvicorn mcp_client.main:app --reload --port 8081
API
POST /chat
MCP .
:
{
"query": "GitHub ",
"thread_id": "optional_thread_id"
}
:
{
"response": "GitHub ",
"used_tools": [
{
"name": "create_github_issue",
"arguments": {"title": "...", "body": "..."},
"result": {"url": "..."}
}
],
"status": "success",
"trace": {
"tool_names": ["create_github_issue"],
"model_rounds": 2,
"thread_id": "thread_123"
}
}
GET /health
.
:
{
"status": "ok",
"details": {
"mcp_client": {"status": "connected", "tool_count": 5},
"workflow": "ready",
"tools_available": 5
}
}
GET /workflow/info
.
:
{
"status": "success",
"workflow_info": {
"model": "gpt-4o",
"temperature": 0.1,
"nodes": ["agent"],
"checkpointer": "MemorySaver"
}
}
MCPClientManager (mcp_client/mcp_client.py)
langchain-mcp-adaptersMultiServerMCPClient
MCPAgentWorkflow (mcp_client/agent/workflow.py)
- LangGraph
StateGraphReAct - Azure OpenAI MCP
mcp_client/
__init__.py
main.py # FastAPI
config.py #
schemas.py # Pydantic
mcp_client.py # MCP
agent/
__init__.py
workflow.py # LangGraph
#
pytest
#
pytest tests/ -v
#
pytest --cov=mcp_client
#
ruff check .
#
ruff format .
#
mypy mcp_client/
- Python 3.11+
- FastAPI -
- LangGraph -
- langchain-mcp-adapters - MCP
- langchain-openai - Azure OpenAI
- Pydantic -
- Uvicorn - ASGI
-
**MCP **
- MCP
MCP_SERVER_URL
-
**Azure OpenAI **
- API
- API
-
**Import **
pip install -r requirements.txt
:
uvicorn mcp_client.main:app --reload --port 8081 --log-level debug
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT .
:
- GitHub Issues
****: MCP GitHub + MCP Client Team
** **: 2025-09-04
****: 0.1.0