abhishekbhakat 247835e595 Refactor Google and OpenAI provider response handling and tool utilities
- Improved error handling and logging in Google response processing.
- Simplified streaming content extraction and error detection in Google provider.
- Enhanced content extraction logic in OpenAI provider to handle edge cases.
- Streamlined tool conversion functions for both Google and OpenAI providers.
- Removed redundant comments and improved code readability across multiple files.
- Updated context window retrieval and message truncation logic for better performance.
- Ensured consistent handling of tool calls and arguments in OpenAI responses.
2025-03-28 04:20:39 +00:00

Streamlit Chat App with MCP Integration

A powerful chat application built with Streamlit that integrates with OpenAI's API and Model Context Protocol (MCP) for enhanced tool capabilities.

Features

  • 💬 Interactive chat interface with Streamlit
  • 🧠 OpenAI API integration with model selection
  • 🛠️ MCP server management and tool integration
  • Both streaming and non-streaming response modes
  • 🔄 Automatic tool discovery and invocation

Installation

  1. Clone the repository:
git clone https://git.bhakat.dev/abhishekbhakat/mcpapp.git
cd mcpapp
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  1. Install dependencies:
pip install -e .

Configuration

  1. Copy the sample config files:
cp config/sample_config.ini config/config.ini
cp config/sample_mcp_config.json config/mcp_config.json
  1. Edit config/config.ini with your OpenAI API key and preferences:
[openai]
api_key = your_api_key_here
base_url = https://api.openai.com/v1
model = gpt-3.5-turbo

[dolphin-mcp]
servers_json = config/mcp_config.json
  1. Configure MCP servers in config/mcp_config.json:
{
    "mcpServers": {
        "example-server": {
            "command": "uvx",
            "args": ["mcp-server-example"],
            "env": {
                "API_KEY": "your-api-key"
            }
        }
    }
}

Usage

Start the application:

uv run mcpapp

The app will be available at http://localhost:8501

Architecture

Key components:

  • src/app.py: Main Streamlit application
  • src/openai_client.py: OpenAI API client with MCP integration
  • src/mcp_manager.py: Synchronous wrapper for MCP server management
  • src/custom_mcp_client/: Custom MCP client implementation

Development


### Code Formatting
```bash
ruff check . --fix

Building

uv build

License

MIT License - See LICENSE for details.

Description
No description provided
Readme 423 KiB
Languages
Python 100%