Skip to content

Commit 2e08322

Browse files
authored
Merge pull request microsoft#1 from madebygps/add-part3
Add part3
2 parents 6949a36 + 09ef218 commit 2e08322

File tree

9 files changed

+1795
-594
lines changed

9 files changed

+1795
-594
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vscode/mcp.json
2+
AIResearchHub/__pycache__/paper_manager.cpython-313.pyc
3+
AIResearchHub/__pycache__/server.cpython-313.pyc
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"id": 1,
4+
"topic": "few shot learning",
5+
"created": "2025-07-14T14:50:54.749520",
6+
"status": "complete",
7+
"papers_found": [
8+
{
9+
"title": "EASY: Ensemble Augmented-Shot Y-shaped Learning: State-Of-The-Art Few-Shot Classification with Simple Ingredients",
10+
"authors": "Yassir Bendou, Yuqing Hu, Raphael Lafargue, Giulia Lioi, Bastien Pasdeloup, St\u00e9phane Pateux, Vincent Gripon",
11+
"url": "https://hf.co/papers/2201.09699"
12+
},
13+
{
14+
"title": "Few-shot Learning with Multilingual Language Models",
15+
"authors": "Xi Victoria Lin, Todor Mihaylov, Mikel Artetxe, Tianlu Wang, Shuohui Chen, Daniel Simig, Myle Ott, Naman Goyal",
16+
"url": "https://hf.co/papers/2112.10668"
17+
},
18+
{
19+
"title": "Enhancing Environmental Robustness in Few-shot Learning via Conditional Representation Learning",
20+
"authors": "Qianyu Guo, Jingrong Wu, Tianxing Wu, Haofen Wang, Weifeng Ge, Wenqiang Zhang",
21+
"url": "https://hf.co/papers/2502.01183"
22+
},
23+
{
24+
"title": "Pushing the Limits of Simple Pipelines for Few-Shot Learning: External Data and Fine-Tuning Make a Difference",
25+
"authors": "Shell Xu Hu, Da Li, Jan St\u00fchmer, Minyoung Kim, Timothy M. Hospedales",
26+
"url": "https://hf.co/papers/2204.07305"
27+
}
28+
],
29+
"repositories_found": [
30+
{
31+
"name": "oscarknagg/few-shot",
32+
"url": "https://github.com/oscarknagg/few-shot",
33+
"stars": 1259
34+
},
35+
{
36+
"name": "sicara/easy-few-shot-learning",
37+
"url": "https://github.com/sicara/easy-few-shot-learning",
38+
"stars": 1225
39+
},
40+
{
41+
"name": "RL-VIG/LibFewShot",
42+
"url": "https://github.com/RL-VIG/LibFewShot",
43+
"stars": 1028
44+
},
45+
{
46+
"name": "huggingface/setfit",
47+
"url": "https://github.com/huggingface/setfit",
48+
"stars": 2522
49+
},
50+
{
51+
"name": "tata1661/FSL-Mate",
52+
"url": "https://github.com/tata1661/FSL-Mate",
53+
"stars": 1746
54+
}
55+
],
56+
"notes": "Comprehensive research completed on few-shot learning. Found key papers covering state-of-the-art methods, environmental robustness, multilingual approaches, and simple pipeline improvements. Identified practical implementations including comprehensive libraries (LibFewShot, FSL-Mate), ready-to-use frameworks (SetFit by HuggingFace), and tutorial-focused repositories (easy-few-shot-learning). The research spans both theoretical advances and practical implementation resources."
57+
}
58+
]

AIResearchHub/paper_manager.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import json
2+
from datetime import datetime
3+
from pathlib import Path
4+
from typing import Any
5+
6+
7+
class PaperManager:
8+
"""Simple paper manager that matches the minimal server needs."""
9+
10+
def __init__(self):
11+
"""Initialize with JSON storage."""
12+
self.data_dir = Path("data")
13+
self.data_dir.mkdir(exist_ok=True)
14+
self.papers_file = self.data_dir / "research_papers.json"
15+
16+
def load_papers(self) -> list[dict]:
17+
"""Load papers from JSON file."""
18+
if self.papers_file.exists():
19+
return json.loads(self.papers_file.read_text())
20+
return []
21+
22+
def save_papers(self, papers: list[dict]):
23+
"""Save papers to JSON file."""
24+
self.papers_file.write_text(json.dumps(papers, indent=2))
25+
26+
def add_research_entry(self, topic: str) -> dict[str, Any]:
27+
"""Add a new research entry for a topic."""
28+
papers = self.load_papers()
29+
30+
research_entry = {
31+
"id": len(papers) + 1,
32+
"topic": topic,
33+
"created": datetime.now().isoformat(),
34+
"status": "pending",
35+
"papers_found": [],
36+
"repositories_found": [],
37+
"notes": ""
38+
}
39+
40+
papers.append(research_entry)
41+
self.save_papers(papers)
42+
43+
return research_entry
44+
45+
def add_paper_to_research(self, research_id: int, paper_data: dict):
46+
"""Add a paper to an existing research entry."""
47+
papers = self.load_papers()
48+
49+
for entry in papers:
50+
if entry["id"] == research_id:
51+
entry["papers_found"].append({
52+
"title": paper_data.get("title", ""),
53+
"authors": paper_data.get("authors", ""),
54+
"url": paper_data.get("url", "")
55+
})
56+
break
57+
58+
self.save_papers(papers)
59+
60+
def add_repo_to_research(self, research_id: int, repo_data: dict):
61+
"""Add a repository to an existing research entry."""
62+
papers = self.load_papers()
63+
64+
for entry in papers:
65+
if entry["id"] == research_id:
66+
entry["repositories_found"].append({
67+
"name": repo_data.get("name", ""),
68+
"url": repo_data.get("url", ""),
69+
"stars": repo_data.get("stars", 0)
70+
})
71+
break
72+
73+
self.save_papers(papers)
74+
75+
def get_research_summary(self) -> dict[str, Any]:
76+
"""Get summary of all research activities."""
77+
papers = self.load_papers()
78+
79+
return {
80+
"total_research": len(papers),
81+
"entries": papers,
82+
"last_updated": datetime.now().isoformat()
83+
}
84+
85+
def update_research_status(self, research_id: int, status: str, notes: str = ""):
86+
"""Update the status of a research entry."""
87+
papers = self.load_papers()
88+
89+
for entry in papers:
90+
if entry["id"] == research_id:
91+
entry["status"] = status
92+
if notes:
93+
entry["notes"] = notes
94+
break
95+
96+
self.save_papers(papers)

AIResearchHub/server.py

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
import json
2+
3+
from fastmcp import FastMCP
4+
from paper_manager import PaperManager
5+
6+
# Initialize MCP server and paper manager
7+
mcp = FastMCP("AI Research Hub")
8+
paper_manager = PaperManager()
9+
10+
@mcp.tool(description="Start researching a topic and get research ID")
11+
async def research_topic(topic: str) -> dict:
12+
"""
13+
Create a new research entry for tracking papers and implementations
14+
15+
Args:
16+
topic: Research topic to investigate
17+
18+
Returns:
19+
Research entry details with tracking ID
20+
"""
21+
research_entry = paper_manager.add_research_entry(topic)
22+
23+
return {
24+
"success": True,
25+
"topic": topic,
26+
"research_id": research_entry["id"],
27+
"message": f"Research entry #{research_entry['id']} created for '{topic}'",
28+
"total_research_topics": len(paper_manager.load_papers())
29+
}
30+
31+
@mcp.tool(description="Get GitHub search strategies for finding implementations")
32+
async def get_github_searches(topic: str) -> dict:
33+
"""
34+
Generate GitHub search commands for finding code implementations
35+
36+
Args:
37+
topic: Research topic to find implementations for
38+
39+
Returns:
40+
GitHub search strategies and commands
41+
"""
42+
return {
43+
"success": True,
44+
"topic": topic,
45+
"github_searches": [f"{topic} implementation", f"{topic} python"],
46+
"commands": [f"Search repos: {topic} stars:>10"],
47+
"instructions": "Use GitHub MCP with these search terms"
48+
}
49+
50+
@mcp.tool(description="Add a paper to a research entry")
51+
async def add_paper(research_id: int, title: str, authors: str = "", url: str = "") -> dict:
52+
"""
53+
Add a research paper to an existing research entry
54+
55+
Args:
56+
research_id: ID of the research entry to add to
57+
title: Title of the paper
58+
authors: Paper authors (optional)
59+
url: URL to the paper (optional)
60+
61+
Returns:
62+
Success status and details
63+
"""
64+
paper_data = {
65+
"title": title,
66+
"authors": authors,
67+
"url": url
68+
}
69+
70+
paper_manager.add_paper_to_research(research_id, paper_data)
71+
72+
return {
73+
"success": True,
74+
"research_id": research_id,
75+
"paper_added": title,
76+
"message": f"Paper '{title}' added to research #{research_id}"
77+
}
78+
79+
@mcp.tool(description="Add a repository to a research entry")
80+
async def add_repository(research_id: int, name: str, url: str = "", stars: int = 0) -> dict:
81+
"""
82+
Add a code repository to an existing research entry
83+
84+
Args:
85+
research_id: ID of the research entry to add to
86+
name: Repository name
87+
url: Repository URL (optional)
88+
stars: Star count (optional)
89+
90+
Returns:
91+
Success status and details
92+
"""
93+
repo_data = {
94+
"name": name,
95+
"url": url,
96+
"stars": stars
97+
}
98+
99+
paper_manager.add_repo_to_research(research_id, repo_data)
100+
101+
return {
102+
"success": True,
103+
"research_id": research_id,
104+
"repository_added": name,
105+
"message": f"Repository '{name}' added to research #{research_id}"
106+
}
107+
108+
@mcp.tool(description="Update research status and add notes")
109+
async def update_research_status(research_id: int, status: str, notes: str = "") -> dict:
110+
"""
111+
Update the status of a research entry
112+
113+
Args:
114+
research_id: ID of the research entry to update
115+
status: New status (pending, active, complete)
116+
notes: Optional notes about the research progress
117+
118+
Returns:
119+
Success status and details
120+
"""
121+
paper_manager.update_research_status(research_id, status, notes)
122+
123+
return {
124+
"success": True,
125+
"research_id": research_id,
126+
"status": status,
127+
"message": f"Research #{research_id} status updated to '{status}'"
128+
}
129+
130+
@mcp.prompt(name="research_workflow")
131+
def research_workflow_prompt(topic: str) -> str:
132+
"""Complete research workflow for any topic"""
133+
return f"""Research Topic: {topic}
134+
135+
WORKFLOW:
136+
1. research_topic(topic="{topic}") - Create research entry
137+
2. Search HuggingFace papers: mcp_huggingface_paper_search(query="{topic}")
138+
3. get_github_searches(topic="{topic}") - Get search strategies
139+
4. Search GitHub repos: mcp_github_search_repositories(query="{topic}")
140+
5. Add findings: add_paper() and add_repository()
141+
6. update_research_status(research_id, "complete") - Mark done
142+
7. Check research://status for dashboard
143+
144+
TOOLS: research_topic, add_paper, add_repository, get_github_searches, update_research_status
145+
GOAL: Link papers with implementations"""
146+
147+
@mcp.resource("status://dashboard")
148+
def research_status() -> str:
149+
"""Current research status and saved topics"""
150+
summary = paper_manager.get_research_summary()
151+
return json.dumps(summary, indent=2)
152+
153+
if __name__ == "__main__":
154+
mcp.run()

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ By the end of this tutorial series, you'll have:
1212
## Tutorial Structure
1313

1414
### [Part 1: Prerequisites and Setup](part1-setup.md)
15+
1516
**⏱️ Time: 15-20 minutes**
1617

1718
Set up your development environment and understand MCP fundamentals:
@@ -59,7 +60,7 @@ Challenge: Create a list comprehension that filters even numbers...
5960

6061
---
6162

62-
### [Part 3: Building Your Own MCP Server - AI Research Learning Assistant](part3-ai-research-server-python.md)
63+
### [Part 3: Building Your Own MCP Server - AI Research Learning Hub](part3-ai-researcher.md)
6364
**⏱️ Time: 20-35 minutes**
6465

6566
**Key Learning Objectives:**
@@ -83,7 +84,7 @@ Build an advanced MCP server that helps you keep up with the latest AI Research:
8384
- `track_learning_progress()` - Monitor study achievements and goals
8485
- `send_research_learning()` - Send study daily study note to the user
8586

86-
**Continue to**: [Part 3: AI Research Learning Hub →](./part3-ai-research.md)
87+
**Continue to**: [Part 3: AI Research Learning Hub →](./part3-ai-researcher.md)
8788

8889
---
8990

@@ -94,8 +95,8 @@ If you're ready to dive in immediately:
9495
1. **Prerequisites**: Ensure you have VS Code, Python 3.12+, Docker and Python extension installed
9596
2. **Choose your path**:
9697
- 🆕 **Need help getting set up?** Start with [Part 1: Setup](part1-setup.md)
97-
- **Want to learn Python with MCP?** Jump to [Part 2: Python Study Buddy](part2-study-buddy.md)
98-
- 🧠 **Ready to build AI research tools?** Go to [Part 3: AI Research Server](part3-ai-research-server.md)
98+
- 🐍 **Want to learn Python with MCP?** Jump to [Part 2: Python Study Buddy](part2-study-buddy.md)
99+
- 🧠 **Ready to build AI research tools?** Go to [Part 3: AI Research Hub](part3-ai-researcher.md)
99100

100101
## Repository Structure
101102

@@ -104,7 +105,7 @@ letslearnmcp-python/
104105
├── README.md # This overview
105106
├── part1-setup.md # Prerequisites and environment setup
106107
├── part2-study-buddy.md # Building Python learning companion
107-
└── part3-ai-research-server.md # Creating AI research discovery server
108+
└── part3-ai-researcher.md # Creating AI research discovery server
108109
```
109110

110111
## Additional Resources

0 commit comments

Comments
 (0)