g

github-MCP-practice

@J-nowcow/github-MCP-practice
0 Stars 179 次浏览 J-nowcow 更新于 2026-08-23

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 :

  1. GitHub Settings > Tokens
  2. : repo, user
  3. :
# .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"
}

  1. :
{
  "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"
  }
}
  1. :
{
  "tool": "createOrUpdateFile",
  "arguments": {
    "owner": "J-nowcow",
    "repo": "github-MCP-practice",
    "path": "README.md",
    "content": "# Updated README\n\nUpdated content here.",
    "message": "Update README"
  }
}
  1. :
{
  "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) :

  1. MCP Server(GitHub)
  2. LangGraph ReAct Agent Azure OpenAI
  3. MCP Server
  4. **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-adapters MultiServerMCPClient

MCPAgentWorkflow (mcp_client/agent/workflow.py)

  • LangGraph StateGraph ReAct
  • 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

  1. **MCP **

    • MCP
    • MCP_SERVER_URL
  2. **Azure OpenAI **

    • API
    • API
  3. **Import **

    • pip install -r requirements.txt

   :
uvicorn mcp_client.main:app --reload --port 8081 --log-level debug

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

MIT .

:

  1. GitHub Issues

****: MCP GitHub + MCP Client Team
** **: 2025-09-04
****: 0.1.0

相关 MCP 服务