### Example CLI Query with Specific MCP Config and Model (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This example demonstrates how to use the CLI with a specific MCP configuration file (`examples/sqlite-mcp.json`) and a specified model (`gpt-4o`). This is useful for testing with specific setups or data. ```bash dolphin-mcp-cli --mcp-config examples/sqlite-mcp.json --model gpt-4o "What dolphin species are endangered?" ``` -------------------------------- ### Install Dolphin MCP Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Instructions for installing the Dolphin MCP package from PyPI and verifying the installation using the command-line interface. ```bash pip install dolphin-mcp dolphin-mcp-cli --help ``` -------------------------------- ### Create Custom MCP Client for Process-Based Servers in Python Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Provides an example of creating a custom MCP client in Python to interact with local subprocess-based MCP servers. It demonstrates how to start the server, list available tools, and call a specific tool with arguments, including environment variables and working directory settings. ```python import asyncio from dolphin_mcp.client import MCPClient async def use_custom_mcp_client(): # Create client for a local MCP server client = MCPClient( server_name="my_custom_server", command="uvx", args=["mcp-server-sqlite", "--db-path", "/path/to/db.sqlite"], env={"CUSTOM_VAR": "value"}, cwd="/working/directory" ) try: # Start the server success = await client.start() if not success: print("Failed to start server") return # List available tools tools = await client.list_tools() print(f"Available tools: {[t['name'] for t in tools]}") # Call a specific tool result = await client.call_tool( tool_name="read_query", arguments={"query": "SELECT * FROM dolphins WHERE status = 'endangered'"} ) print("Tool result:", result) finally: await client.stop() asyncio.run(use_custom_mcp_client()) ``` -------------------------------- ### Example CLI Query with Custom Servers (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This command shows a general example of using the CLI with custom MCP servers configured in your default or specified config file. Replace "Query relevant to your configured servers" with an actual query. ```bash dolphin-mcp-cli "Query relevant to your configured servers" ``` -------------------------------- ### Example CLI Query Specifying a Model (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This example shows how to explicitly specify the language model to be used for processing the query, overriding any default settings. Here, `gpt-4o` is selected. ```bash dolphin-mcp-cli --model gpt-4o "What are the evolutionary relationships between dolphin species?" ``` -------------------------------- ### Example CLI Query with LMStudio Provider (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This command illustrates how to use a model served via LMStudio by specifying the model name. The system will attempt to connect to LMStudio to retrieve results. ```bash dolphin-mcp-cli --model qwen2.5-7b "What are the evolutionary relationships between dolphin species?" ``` -------------------------------- ### Install Dependencies on Linux Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md Installs Python, pip, and SQLite using the apt package manager, and uses a curl script to install uv. ```bash sudo apt update sudo apt install python3 python3-pip sqlite3 curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Connect Custom MCP Client to SSE-Based Servers in Python Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Demonstrates how to use the SSEMCPClient in Python to connect to remote MCP servers using Server-Sent Events (SSE). This example shows how to start the connection, list available tools, and invoke a tool on the remote server. ```python import asyncio from dolphin_mcp.client import SSEMCPClient async def use_sse_client(): # Create SSE client for remote server client = SSEMCPClient( server_name="remote_server", url="http://localhost:8000/sse" ) try: # Start connection success = await client.start() if not success: print("Failed to connect to SSE server") return # List and call tools tools = await client.list_tools() print(f"Available tools: {[t['name'] for t in tools]}") result = await client.call_tool( tool_name="fetch_data", arguments={"id": 123} ) print("Result:", result) finally: await client.stop() asyncio.run(use_sse_client()) ``` -------------------------------- ### Install Dolphin MCP Package Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md Standard installation methods for the Dolphin MCP library and CLI tool via PyPI or source code. ```bash pip install dolphin-mcp ``` ```bash git clone https://github.com/cognitivecomputations/dolphin-mcp.git cd dolphin-mcp pip install -e . cp .env.example .env python setup_db.py ``` -------------------------------- ### Install uv/uvx on Windows Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md Uses PowerShell to download and execute the installation script for the uv package manager on Windows systems. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Fetch and Analyze Filesystem and Web Data with dolphin-mcp-cli Source: https://github.com/quixiai/dolphin-mcp/blob/main/examples/README.md This snippet illustrates using dolphin-mcp-cli to read data from a local text file ('stocklist.txt') and fetch information from a web URL (Yahoo Finance news). It then analyzes the fetched news for specific stocks and provides buy/sell recommendations. This requires a configuration file and specifies the model to use. ```bash dolphin-mcp-cli --mcp-config examples/filesystem-fetch-mcp.json --model gpt-4o "Read ./examples/stocklist.txt and fetch https://finance.yahoo.com/topic/stock-market-news/. If there is positive news about any of the stocks in the list, advise me to buy that stock. if there is negative news about any of the stocks in the list, advise me to sell that stock." ``` -------------------------------- ### Install Dependencies on macOS Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md Installs Python, SQLite, and uv using the Homebrew package manager on macOS. ```bash brew install python brew install sqlite brew install uv ``` -------------------------------- ### Start Interactive Chat with Initial Question (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md You can provide an initial question when starting the interactive chat mode. The CLI will process this question first and then enter the interactive session. ```bash dolphin-mcp-cli -i "What dolphin species are endangered?" ``` -------------------------------- ### Query SQLite Database with dolphin-mcp-cli Source: https://github.com/quixiai/dolphin-mcp/blob/main/examples/README.md This snippet demonstrates how to use dolphin-mcp-cli to interact with a SQLite database. It connects to a database, lists tables, and then selects a random row from the 'dolphin_species' table to generate a story. It requires a configuration file and specifies the model to use. ```bash dolphin-mcp-cli --mcp-config examples/sqlite-mcp.json --model dolphin "Explore the database, and choose one random row - and write a story about it" ``` -------------------------------- ### Example CLI Query with Quiet Mode (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This command runs the CLI with the `--quiet` flag, which suppresses intermediate output, showing only essential information or errors. This is useful for cleaner output when only the final result is needed. ```bash dolphin-mcp-cli --quiet "List all dolphin species in the Atlantic Ocean" ``` -------------------------------- ### Run Interactive CLI Sessions Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Start an interactive conversation mode via the CLI, allowing for continuous dialogue where context is maintained across multiple turns. ```bash dolphin-mcp-cli --interactive dolphin-mcp-cli -i "What dolphin species are endangered?" dolphin-mcp-cli --model claude-3-7-sonnet-latest -i ``` -------------------------------- ### Enable Interactive Chat Mode (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md Use the `--interactive` or `-i` flag to start the `dolphin-mcp-cli` in interactive chat mode. This allows for a continuous conversation where context is maintained across turns. Type 'exit' or 'quit' to end the session. ```bash dolphin-mcp-cli --interactive # or dolphin-mcp-cli -i ``` -------------------------------- ### Configure System and Database Environment Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Commands to initialize the demo SQLite database and configure necessary API credentials via environment variables for the Dolphin MCP ecosystem. ```bash # Run the setup script python setup_db.py # Query using the CLI dolphin-mcp-cli --mcp-config examples/sqlite-mcp.json "List all dolphins" ``` ```bash # Create .env file cat > .env << EOF OPENAI_API_KEY=sk-your-openai-key ANTHROPIC_API_KEY=sk-ant-your-anthropic-key ANTHROPIC_RATE_LIMIT_SECONDS=60 ANTHROPIC_CACHING_ENABLED=true EOF # Export manually export OPENAI_API_KEY=sk-your-key export ANTHROPIC_API_KEY=sk-ant-your-key ``` -------------------------------- ### Configure LLM Providers with YAML Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Illustrates how to configure various Large Language Model (LLM) providers and their models using a YAML file. This configuration includes model names, API keys, and specific parameters like temperature and max tokens for different providers such as OpenAI, Anthropic, Ollama, LM Studio, and Azure OpenAI. ```yaml models: - model: gpt-4o title: gpt-4o provider: openai apiKey: "sk-your-key-here" temperature: 0.7 max_tokens: 2048 default: true - model: claude-3-7-sonnet-latest provider: anthropic apiKey: "sk-ant-your-key" title: claude temperature: 0.7 top_k: 256 top_p: 0.9 max_tokens: 2048 - model: dolphin3-24b title: dolphin provider: ollama temperature: 0.7 - model: qwen2.5-coder-32b-instruct-mlx title: lms_llama provider: lmstudio systemMessage: "You are a helpful assistant that uses tools when appropriate." - model: my-deployment title: azure-gpt4 provider: msazureopenai apiKey: "your-azure-key" apiBase: "https://your-resource.openai.azure.com" apiVersion: "2024-02-15-preview" ``` -------------------------------- ### Command-line Options for dolphin-mcp-cli Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This lists the available command-line options for the `dolphin-mcp-cli` tool. It covers model selection, output control, interactive mode, configuration file paths, logging, and debugging. ```text Usage: dolphin-mcp-cli [--model ] [--quiet] [--interactive | -i] [--config ] [--mcp-config ] [--log-messages ] [--debug] ['your question'] Options: --model Specify the model to use (e.g., gpt-4o, dolphin, qwen2.5-7b) --quiet Suppress intermediate output (except errors) --interactive, -i Enable interactive chat mode. If selected, 'your question' argument is optional for the first turn. --config Specify a custom config file for LLM providers (default: config.yml) --mcp-config Specify a custom config file for MCP servers (default: examples/sqlite-mcp.json) --log-messages Log all LLM interactions to a JSONL file --debug Enable debug logging (Note: `cli.py` sets DEBUG level by default currently) --help, -h Show this help message ``` -------------------------------- ### Stream Responses Token-by-Token with Python Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Demonstrates how to stream responses token-by-token for real-time output using the MCPAgent. This feature is supported for OpenAI and Azure OpenAI. It requires the 'dolphin_mcp' library and depends on a configuration file for provider settings. ```python import asyncio from dolphin_mcp import MCPAgent from dolphin_mcp.utils import load_config_from_file async def streaming_conversation(): provider_config = await load_config_from_file("config.yml") agent = await MCPAgent.create( model_name="gpt-4o", provider_config=provider_config, mcp_server_config_path="examples/sqlite-mcp.json", quiet_mode=True, stream=True # Enable streaming ) try: # Get streaming response response_generator = await agent.prompt("What are the top 5 largest dolphin species?") # Process tokens as they arrive full_response = "" async for token in response_generator: print(token, end="", flush=True) full_response += token print() # Newline after response finally: await agent.cleanup() asyncio.run(streaming_conversation()) ``` -------------------------------- ### Define MCP Servers for Tool Access with JSON Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Shows how to define MCP (Model Context Protocol) servers in a JSON configuration file. This specifies the servers to connect to for accessing various tools, including their commands, arguments, and endpoints. ```json { "mcpServers": { "dolphin-demo-database-sqlite": { "command": "uvx", "args": [ "mcp-server-sqlite", "--db-path", "~/.dolphin/dolphin.db" ] }, "filesystem-server": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory" ] }, "remote-sse-server": { "url": "http://localhost:8000/sse" } } } ``` -------------------------------- ### Configure OpenAI API Key and Model (.env) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This snippet shows the format for the .env file, which stores your OpenAI API key and the desired model. Ensure the OPENAI_API_KEY is set to your actual key. The OPENAI_BASE_URL can be uncommented and modified if you are using a custom OpenAI API endpoint. ```env OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-4o # OPENAI_BASE_URL=https://api.openai.com/v1 # Uncomment and modify if using a custom base url ``` -------------------------------- ### Execute CLI Queries Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Use the dolphin-mcp-cli tool to execute queries against configured MCP servers. Supports custom model selection, configuration file overrides, quiet mode, and message logging. ```bash dolphin-mcp-cli "What dolphin species are endangered?" dolphin-mcp-cli --model gpt-4o "List all dolphin species in the Atlantic Ocean" dolphin-mcp-cli --config my_config.yml --mcp-config my_servers.json "Query here" dolphin-mcp-cli --quiet "What are the evolutionary relationships between dolphin species?" dolphin-mcp-cli --log-messages interactions.jsonl "Your query" ``` -------------------------------- ### Run Dolphin MCP CLI with a Query (Bash) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This is the basic command to run the Dolphin MCP CLI with a user query. The query is passed as a string argument, and the tool will process it using the configured MCP servers and language model. ```bash dolphin-mcp-cli "Your query here" ``` -------------------------------- ### Execute Legacy Dolphin MCP Script (Python) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This command shows how to run the original `dolphin_mcp.py` script directly. This script performs the core actions of connecting to MCP servers, listing tools, interacting with the language model, and executing tool calls. ```bash python dolphin_mcp.py "Your query here" ``` -------------------------------- ### Define MCP Servers Configuration (mcp_config.json) Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This JSON snippet defines the structure for the mcp_config.json file, specifying MCP servers to connect to. Each server can have a command, arguments, and environment variables. The client connects to all listed servers, making their tools available. ```json { "mcpServers": { "server1": { "command": "command-to-start-server", "args": ["arg1", "arg2"], "env": { "ENV_VAR1": "value1", "ENV_VAR2": "value2" } }, "server2": { "command": "another-server-command", "args": ["--option", "value"] } } } ``` -------------------------------- ### Run Dolphin MCP as a Python Library Source: https://github.com/quixiai/dolphin-mcp/blob/main/README.md This Python snippet demonstrates how to use the Dolphin MCP library programmatically. The `run_interaction` function handles the process of sending a query to the language model and executing tools. You can specify the model, config path, and quiet mode. ```python import asyncio from dolphin_mcp import run_interaction async def main(): result = await run_interaction( user_query="What dolphin species are endangered?", model_name="gpt-4o", # Optional, will use default from config if not specified config_path="mcp_config.json", # Optional, defaults to mcp_config.json quiet_mode=False # Optional, defaults to False ) print(result) # Run the async function asyncio.run(main()) ``` -------------------------------- ### Perform Direct LLM Provider Invocations Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Demonstrates how to bypass the MCP client layer to interact directly with OpenAI and Anthropic models. These functions accept conversation history, model configurations, and tool definitions to return structured assistant responses. ```python import asyncio from dolphin_mcp.providers.openai import generate_with_openai async def direct_openai_call(): conversation = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the capital of France?"} ] model_cfg = { "model": "gpt-4o", "apiKey": "sk-your-key", "temperature": 0.7, "max_tokens": 1024 } functions = [ { "name": "get_weather", "description": "Get weather for a location", "parameters": { "type": "object", "properties": { "location": {"type": "string"} }, "required": ["location"] } } ] result = await generate_with_openai( conversation=conversation, model_cfg=model_cfg, all_functions=functions, stream=False ) print("Response:", result["assistant_text"]) print("Tool calls:", result["tool_calls"]) asyncio.run(direct_openai_call()) ``` ```python import asyncio import os from dolphin_mcp.providers.anthropic import generate_with_anthropic async def direct_anthropic_call(): os.environ["ANTHROPIC_RATE_LIMIT_SECONDS"] = "60" os.environ["ANTHROPIC_CACHING_ENABLED"] = "true" conversation = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain quantum computing in simple terms."} ] model_cfg = { "model": "claude-3-7-sonnet-latest", "apiKey": "sk-ant-your-key", "temperature": 0.7, "top_k": 256, "top_p": 0.9, "max_tokens": 2048 } functions = [] result = await generate_with_anthropic( conversation=conversation, model_cfg=model_cfg, all_functions=functions ) print("Response:", result["assistant_text"]) asyncio.run(direct_anthropic_call()) ``` -------------------------------- ### Perform Single Python Interaction Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Use the run_interaction function in Python to perform a one-shot query against MCP servers programmatically. Requires configuring the provider and server paths. ```python import asyncio from dolphin_mcp import run_interaction async def query_mcp_servers(): result = await run_interaction( user_query="What dolphin species are endangered?", model_name="gpt-4o", provider_config_path="config.yml", mcp_server_config_path="examples/sqlite-mcp.json", quiet_mode=False, log_messages_path="interactions.jsonl", stream=False ) print(result) asyncio.run(query_mcp_servers()) ``` -------------------------------- ### Manage Multi-Turn Conversations with MCPAgent Source: https://context7.com/quixiai/dolphin-mcp/llms.txt Utilize the MCPAgent class to establish a persistent session with an LLM and MCP tools, allowing for complex, multi-turn interactions with shared conversational context. ```python import asyncio from dolphin_mcp import MCPAgent from dolphin_mcp.utils import load_config_from_file async def interactive_conversation(): provider_config = await load_config_from_file("config.yml") agent = await MCPAgent.create( model_name="gpt-4o", provider_config=provider_config, mcp_server_config_path="examples/sqlite-mcp.json", quiet_mode=False, log_messages_path="chat_log.jsonl", stream=False ) try: response1 = await agent.prompt("What dolphin species are endangered?") print("Response 1:", response1) response2 = await agent.prompt("Tell me more about the first species you mentioned") print("Response 2:", response2) response3 = await agent.prompt("What is their conservation status?") print("Response 3:", response3) finally: await agent.cleanup() asyncio.run(interactive_conversation()) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.