-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
68 lines (54 loc) · 2.02 KB
/
Copy pathserver.py
File metadata and controls
68 lines (54 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
My First MCP Server — DevRel Community Toolkit
A beginner-friendly MCP server built while learning MCP for the AAIF Ambassador program.
Install: pip install "mcp[cli]"
Run: mcp dev server.py (opens the MCP Inspector for testing)
Connect: Add to Claude Desktop config (see README.md)
"""
from datetime import date
from mcp.server.fastmcp import FastMCP
# Create the server — the name shows up in the client (e.g. Claude Desktop)
mcp = FastMCP("community-toolkit")
@mcp.tool()
def days_until_event(event_date: str) -> str:
"""Count days until a community event. Date format: YYYY-MM-DD."""
target = date.fromisoformat(event_date)
delta = (target - date.today()).days
if delta < 0:
return f"That event was {-delta} days ago."
if delta == 0:
return "The event is today! 🎉"
return f"{delta} days until the event."
@mcp.tool()
def meetup_announcement(
event_name: str,
event_date: str,
location: str,
signup_url: str,
) -> str:
"""Generate a ready-to-post meetup announcement in Markdown."""
return (
f"# 📣 {event_name}\n\n"
f"**When:** {event_date}\n"
f"**Where:** {location}\n\n"
f"Join fellow builders for talks, demos, and community time.\n\n"
f"👉 [Register here]({signup_url})\n"
)
@mcp.tool()
def thank_you_note(contributor_name: str, contribution: str) -> str:
"""Draft a short thank-you note for a community contributor."""
return (
f"Hey {contributor_name}! 👋\n\n"
f"Huge thanks for {contribution} — contributions like this are what "
f"keep this community thriving. We appreciate you!\n"
)
@mcp.resource("community://about")
def about() -> str:
"""A resource the AI client can read for context about this server."""
return (
"Community Toolkit MCP server: small utilities for DevRel and "
"community managers — event countdowns, meetup announcements, "
"and contributor thank-you notes."
)
if __name__ == "__main__":
mcp.run()