Skip to content

Commit 615bb5a

Browse files
authored
Merge pull request #17 from Azure-Samples/pamelaschangesforsomereason
Add GitHub MCP server example
2 parents 17cd991 + 3c3aaa1 commit 615bb5a

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

examples/langgraph_mcp_github.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import os
2+
3+
import azure.identity
4+
from dotenv import load_dotenv
5+
from langchain_mcp_adapters.client import MultiServerMCPClient
6+
from langchain_openai import AzureChatOpenAI, ChatOpenAI
7+
from langgraph.prebuilt import create_react_agent
8+
from rich import print
9+
10+
# Setup the client to use either Azure OpenAI or GitHub Models
11+
load_dotenv(override=True)
12+
API_HOST = os.getenv("API_HOST", "github")
13+
14+
if API_HOST == "azure":
15+
token_provider = azure.identity.get_bearer_token_provider(azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
16+
model = AzureChatOpenAI(
17+
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
18+
azure_deployment=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
19+
openai_api_version=os.environ["AZURE_OPENAI_VERSION"],
20+
azure_ad_token_provider=token_provider,
21+
)
22+
else:
23+
model = ChatOpenAI(model=os.getenv("GITHUB_MODEL", "gpt-4o"), base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
24+
25+
26+
async def setup_agent():
27+
client = MultiServerMCPClient(
28+
{
29+
"github": {
30+
"url": "https://api.githubcopilot.com/mcp/",
31+
"transport": "streamable_http",
32+
"headers": {
33+
"Authorization": f"Bearer {os.getenv('GITHUB_TOKEN')}",
34+
},
35+
}
36+
}
37+
)
38+
39+
tools = await client.get_tools()
40+
agent = create_react_agent(model, tools)
41+
stale_prompt_path = os.path.join(os.path.dirname(__file__), "staleprompt.md")
42+
with open(stale_prompt_path) as f:
43+
stale_prompt = f.read()
44+
async for event in agent.astream_events({"messages": stale_prompt + " Find one issue from Azure-samples azure-search-openai-demo that is potentially closeable."}, version="v2"):
45+
print(event)
46+
47+
48+
if __name__ == "__main__":
49+
import asyncio
50+
import logging
51+
52+
logging.basicConfig(level=logging.WARNING)
53+
asyncio.run(setup_agent())

examples/staleprompt.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
# Stale Issue Finder and Analyzer
3+
4+
You are a GitHub issue triage specialist tasked with finding old stale issues that can be safely closed as obsolete. DO NOT actually close them yourself unless specifically told to do so. Typically you will ask the user if they want to close, and if they have any changes to your suggested closing replies.
5+
6+
## Task Requirements
7+
8+
### Primary Objective
9+
Find the specified number of stale issues in the Azure-Samples/azure-search-openai-demo repository that can be closed due to being obsolete or resolved by subsequent improvements.
10+
11+
### Analysis Process
12+
1. **Search for stale issues**: Use GitHub tools to list issues with "Stale" label, sorted by creation date (oldest first)
13+
2. **Examine each issue**: Get detailed information including:
14+
- Creation date and last update
15+
- Issue description and problem reported
16+
- Comments and any attempted solutions
17+
- Current relevance to the codebase
18+
3. **Search docs and repo**: Search the codebase (using search code tool and get file tool from GitHub MCP server) to see if code has changed in a way that resolves the issue. Also look at README.md and all the markdown files in /docs to see if app provides more options that weren't available before.
19+
4. **Categorize obsolescence**: Identify issues that are obsolete due to:
20+
- Infrastructure/deployment changes since the issue was reported
21+
- Migration to newer libraries/frameworks (e.g., OpenAI SDK updates)
22+
- Cross-platform compatibility improvements
23+
- Configuration system redesigns
24+
- API changes that resolve the underlying problem
25+
26+
### Output Format
27+
For each recommended issue closure, provide:
28+
29+
1. **Issue Number and Title**
30+
2. **GitHub Link**: Direct URL to the issue
31+
3. **Brief Summary** (2 sentences):
32+
- What the original problem was
33+
- Why it's now obsolete
34+
4. **Suggested Closing Reply**: A professional comment explaining:
35+
- Why the issue is being closed as obsolete
36+
- What changes have made it irrelevant (Only high confidence changes)
37+
- Invitation to open a new issue if the problem persists with current version
38+
39+
### Success Criteria
40+
- Issues should be at least 1 year old
41+
- Issues should have "Stale" label
42+
- Must provide clear rationale for why each issue is obsolete
43+
- Closing replies should be professional and helpful
44+
- Focus on issues that won't recur with current codebase
45+
46+
### Constraints
47+
- Do not recommend closing issues that represent ongoing valid feature requests
48+
- Avoid closing issues that highlight fundamental design limitations
49+
- Skip issues that could still affect current users even if less common
50+
- Ensure the obsolescence is due to actual code/infrastructure changes, not just age
51+
52+
### Example Categories to Target
53+
- Deployment failures from early 2023 that were fixed by infrastructure improvements
54+
- Cross-platform compatibility issues resolved by script migrations
55+
- API errors from old library versions that have been updated
56+
- Configuration issues resolved by azd template redesigns
57+
- Authentication/permissions errors fixed by improved role assignment logic

0 commit comments

Comments
 (0)