Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
*.DS_Store
sandbox/
dist/
example/credentials.json
example/gmail_token.json
example/token.json
143 changes: 143 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Elkar A2A Google Services Integration

This project integrates Google Calendar and Gmail services with Elkar A2A, providing powerful email and calendar management capabilities.

## Prerequisites

- Python 3.8 or higher
- Google Cloud Platform account
- Claude Desktop application

## Installation

1. Clone the repository:
```bash
git clone https://github.com/yourusername/elkar-a2a.git
cd elkar-a2a
```

2. Install the required dependencies:
```bash
pip install -r requirements.txt
```

This will install all necessary packages including:
- Core dependencies (crewai, langchain, elkar)
- Google API dependencies
- Web server dependencies (uvicorn, fastapi)
- Database dependencies
- Utility dependencies
- MCP dependencies

## Google Services Setup

### 1. Enable Google APIs

1. Go to the [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select an existing one
3. Enable the following APIs:
- Gmail API
- Google Calendar API
4. Configure the OAuth consent screen:
- Set up the OAuth consent screen with necessary scopes
- Add test users if in testing mode

### 2. Download Credentials

1. In the Google Cloud Console, go to "APIs & Services" > "Credentials"
2. Click "Create Credentials" > "OAuth client ID"
3. Choose "Desktop application" as the application type
4. Download the credentials file and save it as `credentials.json` in the `example` directory

### 3. First-time Authentication

When you run the application for the first time:
- The system will automatically create `token.json` for Google Calendar
- The system will automatically create `gmail_token.json` for Gmail
- A browser window will open for OAuth authentication
- Grant the requested permissions

## Claude Desktop Configuration

### 1. Configure Claude Desktop

1. Locate your Claude Desktop configuration file:
- Mac: `/Users/mm/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
- Linux: `~/.config/Claude/claude_desktop_config.json`

2. Add the MCP server configuration to the file:
```json
{
"mcpServers": {
"a2a_elkar": {
"command": "/opt/anaconda3/bin/python",
"args": ["path to your server_mcp.py"],
"env": {
"ANTHROPIC_API_KEY": "sk-xxx",
"OPENAI_API_KEY": "sk-yyy",
"AGENT_URLS": "http://localhost:5001,http://localhost:5002"
}
}
}
}
```

### 2. Add Metaprompt

1. Open the Claude Desktop configuration file
2. Add the metaprompt from `claudePrompt.txt` to the appropriate section
3. Save the file

#### Example Claude Desktop Configuration Screenshots

![Claude Desktop Profile Settings](claude_config1.png)

![Claude Desktop General Settings](claude_config2.png)

## Running the Servers

1. Start the Gmail server:
```bash
python example/server.py
```

2. Start the Calendar server:
```bash
python example/server_cal.py
```

The servers will be available at:
- Gmail Assistant: http://localhost:5001
- Calendar Assistant: http://localhost:5002

## Troubleshooting

### Authentication Issues

If you encounter authentication issues:
1. Delete the existing token files (`token.json` and `gmail_token.json`)
2. Run the server with the `force_reauth` parameter
3. Complete the OAuth flow again

### Claude Desktop Issues

If Claude Desktop doesn't recognize the MCP servers:
1. Verify the configuration file path
2. Check the JSON syntax
3. Restart Claude Desktop
4. Ensure the servers are running before starting Claude Desktop

## Security Notes

- Keep your `credentials.json` file secure and never commit it to version control
- Regularly rotate your OAuth credentials
- Monitor the OAuth consent screen for any unauthorized access
- Use environment variables for sensitive configuration

## Support

For issues or questions:
1. Check the troubleshooting section
2. Review the Google Cloud Console logs
3. Check the server logs for detailed error messages
25 changes: 25 additions & 0 deletions example/claudePrompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
At your disposal you have A2A agents, which are specialized tools that provide extended functionalities.
You can invoke these agents to perform tasks you may not be able to do directly.
If you're unsure what capabilities are available, first call the discover_a2a_agents tool, which will list all available agents and their functions.
For example, if you are asked to send a calendar invite or an email invitation, follow this workflow:
Workflow: Sending an Invite (Calendar or Email)
Discover Capabilities:
Call discover_a2a_agents and look for agents with keywords like calendar, email, or invite.
Choose a Tool Based on Goal:
If the goal is to create a calendar event (e.g., Google Calendar) and invite specific participants by email, use the create_calendar_event tool.
If the goal is to just send an email invitation, use the appropriate send_email agent/tool.
Create Calendar Event with Invitees:
When using the calendar agent:
Set the title, start_time, end_time, and description.
Add attendees as a list of email addresses.
Optionally set a location or video_conference_link.
Send an Email Invitation Instead:
When using an email agent:
Set the recipient_email, subject, and body.
Optionally include event details in the email body.
Confirmation:
After calling the tool, check the response for confirmation or errors.
If needed, retry or adjust based on the feedback from the agent/tool.
Example Use Cases:
"Create a Google Calendar event titled Team Sync for tomorrow at 10 AM with [email protected] and [email protected] invited."
"Send an email to [email protected] with subject Meeting Invite and body Let's meet at 2 PM to discuss the roadmap."
Binary file added example/claude_config1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/claude_config2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions example/claude_desktop_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"a2a_elkar": {
"command": "/opt/anaconda3/bin/python",
"args": ["path to your server_mcp.py"],
"env": {
"AGENT_URLS": "http://localhost:5001,http://localhost:5002"
}
},
Loading
Loading