-
Notifications
You must be signed in to change notification settings - Fork 175
Fix variable scope error and add get_info endpoint #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amovfx
wants to merge
7
commits into
elevenlabs:main
Choose a base branch
from
amovfx:fix/elevenlabs-mcp-knowledge-base-variable-scope
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+334
−6
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bd444b3
Update uv.lock
6de56e2
Add transfer_to_agent tool support for conversational AI agents
25ec2d1
Add get_agent_config function to retrieve agent conversation configur…
702c126
Add update_agent_with_tools function to manage built-in tools configu…
6d24fcc
Fix update_agent_with_tools to handle frozen Pydantic models
113a620
Fix variable scope error in add_knowledge_base_to_agent
27cb7e0
Add get_info endpoint to return project location and details
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| This is an ElevenLabs MCP (Model Context Protocol) server that provides access to ElevenLabs' text-to-speech, speech-to-text, voice cloning, and conversational AI capabilities through MCP tools. | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ```bash | ||
| # Setup development environment | ||
| uv venv | ||
| source .venv/bin/activate | ||
| uv pip install -e ".[dev]" | ||
|
|
||
| # Run tests with coverage | ||
| ./scripts/test.sh | ||
| ./scripts/test.sh --verbose --fail-fast # For quick feedback during development | ||
|
|
||
| # Run development server with MCP Inspector | ||
| ./scripts/dev.sh | ||
| # Or directly: mcp dev elevenlabs_mcp/server.py | ||
|
|
||
| # Build package | ||
| ./scripts/build.sh | ||
|
|
||
| # Deploy to PyPI (requires PyPI credentials) | ||
| ./scripts/deploy.sh | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Core Components | ||
|
|
||
| 1. **`server.py`** - Main MCP server implementation | ||
| - Contains all 24 MCP tools decorated with `@mcp.tool` | ||
| - Each tool that makes API calls includes cost warnings | ||
| - Tools return `TextContent` with operation results | ||
|
|
||
| 2. **`utils.py`** - Shared utilities | ||
| - `make_output_path()` - Handles base path configuration | ||
| - `make_output_file()` - Generates timestamped output filenames | ||
| - `handle_input_file()` - Validates and resolves input file paths | ||
| - `find_similar_files()` - Fuzzy file matching for better UX | ||
|
|
||
| 3. **`convai.py`** - Conversational AI configuration builders | ||
| - `create_conversation_config()` - Builds agent conversation settings | ||
| - `create_platform_settings()` - Configures privacy and limits | ||
|
|
||
| 4. **`model.py`** - Pydantic models for type safety | ||
|
|
||
| ### Key Design Patterns | ||
|
|
||
| **Cost-Aware API Tools**: Every tool that calls ElevenLabs API has a cost warning in its description: | ||
| ```python | ||
| @mcp.tool( | ||
| description="""... | ||
| COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user. | ||
| """ | ||
| ) | ||
| ``` | ||
|
|
||
| **File Path Handling**: All file operations respect the `ELEVENLABS_MCP_BASE_PATH` environment variable: | ||
| - If set: Files saved to specified directory | ||
| - If not set: Files saved to user's Desktop | ||
| - Input files can be absolute or relative paths | ||
|
|
||
| **Error Handling**: Custom `ElevenLabsMcpError` exception with helpful messages: | ||
| - File not found ’ Suggests similar files if available | ||
| - Permission errors ’ Clear guidance on file access issues | ||
|
|
||
| ### Environment Configuration | ||
|
|
||
| Required environment variables: | ||
| - `ELEVENLABS_API_KEY` - Your ElevenLabs API key (required) | ||
| - `ELEVENLABS_MCP_BASE_PATH` - Base directory for file operations (optional) | ||
|
|
||
| ### Adding New Tools | ||
|
|
||
| 1. Add tool function in `server.py` with `@mcp.tool` decorator | ||
| 2. Include cost warning if it makes API calls | ||
| 3. Use consistent parameter patterns (see existing tools) | ||
| 4. Return `TextContent` with clear success/error messages | ||
| 5. Handle file operations through utility functions | ||
|
|
||
| ### Testing | ||
|
|
||
| - Unit tests focus on utilities and file operations | ||
| - No integration tests for API calls (to avoid costs) | ||
| - Run tests before committing: `./scripts/test.sh` | ||
| - Aim for high coverage on utility functions | ||
|
|
||
| ### Common Development Tasks | ||
|
|
||
| **Adding a new conversational AI feature**: | ||
| 1. Check if ElevenLabs SDK supports it | ||
| 2. Add/update configuration in `convai.py` if needed | ||
| 3. Create tool in `server.py` following existing patterns | ||
| 4. Test with dev server: `./scripts/dev.sh` | ||
|
|
||
| **Debugging file operations**: | ||
| - Set `ELEVENLABS_MCP_BASE_PATH` to a test directory | ||
| - Check file permissions with `handle_input_file()` | ||
| - Use `make_output_file()` for consistent naming | ||
|
|
||
| **Updating agent configurations**: | ||
| - Agent configs are immutable (Pydantic frozen models) | ||
| - Create new configs rather than modifying existing ones | ||
| - Use `create_conversation_config()` for proper structure | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,14 +13,15 @@ def create_conversation_config( | |
| similarity_boost: float, | ||
| turn_timeout: int, | ||
| max_duration_seconds: int, | ||
| tools: list | None = None, | ||
| ) -> dict: | ||
| return { | ||
| "agent": { | ||
| "language": language, | ||
| "prompt": { | ||
| "prompt": system_prompt, | ||
| "llm": llm, | ||
| "tools": [{"type": "system", "name": "end_call", "description": ""}], | ||
| "tools": tools if tools is not None else [{"type": "system", "name": "end_call", "description": ""}], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! thanks for catching this! |
||
| "knowledge_base": [], | ||
| "temperature": temperature, | ||
| **({"max_tokens": max_tokens} if max_tokens else {}), | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add a note here to avoid using hasattr()
seems this agentic coding added a few calls to it we should avoid