Skip to content

Latest commit

 

History

History
239 lines (183 loc) · 5.5 KB

File metadata and controls

239 lines (183 loc) · 5.5 KB

MCP Registry

Model Context Protocol (MCP) tools organized by service. Each tool is a standalone Python function that can be imported and used directly.

Structure

mcp_registry/
├── github/           # GitHub operations
│   ├── create_or_update_file.py
│   ├── push_files.py
│   ├── create_repository.py
│   ├── fork_repository.py
│   ├── create_branch.py
│   ├── create_issue.py
│   ├── create_pull_request.py
│   ├── list_issues.py
│   ├── search_repositories.py
│   ├── search_code.py
│   ├── search_issues.py
│   ├── search_users.py
│   ├── get_file_contents.py
│   └── list_repository_files.py
└── slack/            # Slack operations
    ├── list_channels.py
    ├── post_message.py
    ├── reply_to_thread.py
    ├── add_reaction.py
    ├── get_channel_history.py
    ├── get_thread_replies.py
    ├── get_users.py
    └── get_user_profile.py

GitHub Tools

Authentication

All GitHub tools require an authenticated Github client:

from github import Github

# Initialize client with token
client = Github("your_github_token")

# Or use environment variable
import os
client = Github(os.getenv("GITHUB_TOKEN"))

Available Tools

Repository Operations

  • create_or_update_file: Create or update a single file
  • push_files: Commit multiple files simultaneously
  • create_repository: Create a new repository
  • fork_repository: Fork an existing repository
  • create_branch: Create a new branch

Issue & PR Management

  • create_issue: Create a new issue
  • create_pull_request: Create a pull request
  • list_issues: List repository issues with filtering

Search

  • search_repositories: Search for repositories
  • search_code: Search for code across repositories
  • search_issues: Search for issues
  • search_users: Search for users

File Operations

  • get_file_contents: Get contents of a file
  • list_repository_files: List files in a directory

Example Usage

from github import Github
from mcp_registry.github import create_issue, push_files

client = Github("your_token")

# Create an issue
result = create_issue(
    client=client,
    owner="username",
    repo="repository",
    title="Bug report",
    body="Description of the bug",
    labels=["bug"]
)

# Push multiple files
result = push_files(
    client=client,
    owner="username",
    repo="repository",
    branch="main",
    files=[
        {"path": "file1.py", "content": "print('hello')"},
        {"path": "file2.py", "content": "print('world')"}
    ],
    message="Add new files"
)

Slack Tools

Authentication

All Slack tools require an authenticated WebClient:

from slack_sdk import WebClient

# Initialize client with bot token
client = WebClient(token="xoxb-your-bot-token")

# Or use environment variable
import os
client = WebClient(token=os.getenv("SLACK_BOT_TOKEN"))

Available Tools

Channel Operations

  • list_channels: List public or pre-defined channels
  • get_channel_history: Get recent messages from a channel

Messaging

  • post_message: Post a message to a channel
  • reply_to_thread: Reply to a message thread
  • add_reaction: Add emoji reaction to a message

Thread Operations

  • get_thread_replies: Get all replies in a thread

User Operations

  • get_users: Get workspace users' profiles
  • get_user_profile: Get detailed profile for a specific user

Example Usage

from slack_sdk import WebClient
from mcp_registry.slack import post_message, list_channels

client = WebClient(token="xoxb-your-token")

# List channels
result = list_channels(
    client=client,
    limit=50
)

# Post a message
result = post_message(
    client=client,
    channel_id="C1234567890",
    text="Hello from MCP tools!"
)

# Reply to a thread
from mcp_registry.slack import reply_to_thread

result = reply_to_thread(
    client=client,
    channel_id="C1234567890",
    thread_ts="1234567890.123456",
    text="This is a reply"
)

Error Handling

All tools return a dictionary with a success field:

result = create_issue(...)

if result["success"]:
    print(f"Issue created: {result['url']}")
else:
    print(f"Error: {result['error']}")

Environment Variables

GitHub

  • GITHUB_TOKEN: Personal access token with appropriate permissions

Slack

  • SLACK_BOT_TOKEN: Bot token (starts with xoxb-)
  • SLACK_TEAM_ID: Workspace team ID (optional)

Prerequisites

Install dependencies:

uv add PyGithub slack-sdk pydantic

Design Philosophy

This registry follows the "Code Execution with MCP" pattern:

  1. Minimal Token Usage: Tools are presented as code APIs, not extensive schemas
  2. Progressive Discovery: Load tool definitions only when needed
  3. Direct Execution: Tools are simple Python functions, not wrapped services
  4. Result Filtering: Tools return structured data for easy filtering

Integration with AgentCore

These tools are designed to be used with Amazon Bedrock AgentCore Code Interpreter:

# In AgentCore sandbox
from github import Github
from mcp_registry.github import create_issue

client = Github(os.getenv("GITHUB_TOKEN"))

# Create issue and filter result
result = create_issue(
    client=client,
    owner="myorg",
    repo="myrepo",
    title="Feature request",
    body="Add new feature"
)

# Return only relevant data to model
return {
    "issue_number": result["issue_number"],
    "url": result["url"]
}