Skip to main content
Glama
README.md
# MCP Chat

MCP Chat is a command-line interface application that enables interactive chat capabilities with AI models through the Anthropic API. The application supports document retrieval, command-based prompts, and extensible tool integrations via the MCP (Model Control Protocol) architecture.

## Prerequisites

- Python 3.9+
- Anthropic API Key

## Setup

### Step 1: Configure the environment variables

1. Create or edit the `.env` file in the project root and verify that the following variables are set correctly:

```
ANTHROPIC_API_KEY=""  # Enter your Anthropic API secret key
```

### Step 2: Install dependencies

#### Option 1: Setup with uv (Recommended)

[uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver.

1. Install uv, if not already installed:

```bash
pip install uv
```

2. Create and activate a virtual environment:

```bash
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
```

3. Install dependencies:

```bash
uv pip install -e .
```

4. Run the project

```bash
uv run main.py
```

#### Option 2: Setup without uv

1. Create and activate a virtual environment:

```bash
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
```

2. Install dependencies:

```bash
pip install anthropic python-dotenv prompt-toolkit "mcp[cli]==1.8.0"
```

3. Run the project

```bash
python main.py
```

## Usage

### Basic Interaction

Simply type your message and press Enter to chat with the model.

### Document Retrieval

Use the @ symbol followed by a document ID to include document content in your query:

```
> Tell me about @deposition.md
```

### Commands

Use the / prefix to execute commands defined in the MCP server:

```
> /summarize deposition.md
```

Commands will auto-complete when you press Tab.

## Development

### Adding New Documents

Edit the `mcp_server.py` file to add new documents to the `docs` dictionary.

### Implementing MCP Features

To fully implement the MCP features:

1. Complete the TODOs in `mcp_server.py`
2. Implement the missing functionality in `mcp_client.py`

### Linting and Typing Check

There are no lint or type checks implemented.

### Developemnt Testing
1. To see the tool available to MCP client (in MCP server), run the below command:
- If not running on uv:
    ```
    python mcp_client.py
    ```

- If running on uv:
    ```
    uv run mcp_client.py
    ```
    **Output**:
    ```
    > Tools: meta=None nextCursor=None tools=[Tool(name='read_doc', title=None, description='Read the contents of a document.', inputSchema={'properties': {'doc_id': {'description': 'The ID of the document to read.', 'title': 'Doc Id', 'type': 'string'}}, 'required': ['doc_id'], 'title': 'read_documentArguments', 'type': 'object'}, outputSchema=None, icons=None, annotations=None, meta=None, execution=None), Tool(name='edit_doc', title=None, description='Edit the contents of a document by replacing the old content with new content.', inputSchema={'properties': {'doc_id': {'description': 'The ID of the document to edit.', 'title': 'Doc Id', 'type': 'string'}, 'old_string': {'description': 'The old string of the document, must match including whitespace and punctuation.', 'title': 'Old String', 'type': 'string'}, 'new_string': {'description': 'The new content for the document.', 'title': 'New String', 'type': 'string'}}, 'required': ['doc_id', 'old_string', 'new_string'], 'title': 'edit_documentArguments', 'type': 'object'}, outputSchema=None, icons=None, annotations=None, meta=None, execution=None)]
    ```
2. To run MCP inspector:

    If want to test whether MCP server tools work correctly before connecting to a full application. 
    ```
    uv run mcp dev mcp_server.py
    ```
It opens a window like this in Default browser or enables this local URL *http://127.0.0.1:6275/*
- Showing tools
![alt text](image.png)

- Showing Resources:

    Resources in MCP servers allow you to expose data to clients, similar to GET request handlers in a typical HTTP server. They're perfect for scenarios where you need to fetch information rather than perform actions.
![alt text](image-1.png)

- Showing Prompts:

    Prompts in MCP servers let you define pre-built, high-quality instructions that clients can use instead of writing their own prompts from scratch.
![alt text](image-2.png)
3. Running the MCP Client:
    ```
    uv run main.py
    ```
    **Ouput for testing tools**:
    ```
    (app) anthropic_introduction_to_mcp> uv run main.py
    > what is the contents of the report.pdf document ?
    I'll read the contents of the report.pdf document for you.

    Response:
    The report.pdf document contains details about the state of a 20m condenser tower.
    ```
    **Output for testing resources**:
    ```
    (app) anthropic_introduction_to_mcp> uv run main.py
    > what's in the @report.pdf

    Response:
    The report.pdf contains details about the state of a 20m condenser tower.
    > What's in the @financials.docx
                    deposition.md    Resource  
                    report.pdf       Resource  
                    financials.docx  Resource  
                    outlook.pdf      Resource  
                    plan.md          Resource  
                    spec.txt         Resource  
    ```
    **Output for testing prompts**:
    ```
    (app) anthropic_introduction_to_mcp> uv run main.py
    `> /format plan.md
    I'll help you reformat the document with proper markdown syntax. Let me first read the document to see its current content.
    I can see the document already has a basic markdown header structure. However, it's very minimal with just a title and one sentence. Let me enhance it with more structure to make it a more complete and useful plan document:

    Response:
    Perfect! I've successfully reformatted and enhanced the document with comprehensive markdown syntax. Here's what I added:

    **Changes made:**

    1. **Multiple Header Levels**: Added `##` level 2 headers for different sections (Overview, Implementation Steps, Timeline, Key Stakeholders, Success Criteria)

    2. **Bullet Points**: Created a bulleted list with bold phase names for the Implementation Steps section

    3. **Table**: Added a formatted markdown table showing the Timeline with columns for Phase, Duration, and Status

    4. **Unordered List**: Added a simple bullet list for Key Stakeholders

    5. **Checkboxes**: Used markdown task list syntax (`- [ ]`) for Success Criteria to make it interactive

    The document now has a professional structure with clear organization, making it much more useful as an actual project implementation plan. The markdown formatting makes it easy to read and navigate through different sections.
    > Where the above formatted doc is stored?

    Response:
    The formatted document is stored in **plan.md**.

    This is the document ID that was specified at the beginning, and all the markdown formatting changes I made (including the headers, bullet points, table, and task list) have been saved to this file.
    > I want to see the contents of this document


    Response:
    # Project Implementation Plan

    ## Overview

    The plan outlines the steps for the project's implementation.

    ## Implementation Steps

    - **Phase 1**: Planning and Requirements Gathering
    - **Phase 2**: Design and Architecture
    - **Phase 3**: Development and Testing
    - **Phase 4**: Deployment and Launch
    - **Phase 5**: Monitoring and Maintenance

    ## Timeline

    | Phase | Duration | Status |
    |-------|----------|--------|
    | Phase 1 | 2 weeks | Pending |
    | Phase 2 | 3 weeks | Pending |
    | Phase 3 | 6 weeks | Pending |
    | Phase 4 | 1 week | Pending |
    | Phase 5 | Ongoing | Pending |

    ## Key Stakeholders

    - Project Manager
    - Development Team
    - Quality Assurance Team
    - Operations Team

    ## Success Criteria

    - [ ] All phases completed on schedule
    - [ ] Requirements met and validated
    - [ ] Quality standards achieved
    - [ ] Successful deployment with minimal issues
    ```
    -> Summary:
    
        - Need to give Claude new capabilities? Use tools

        - Need to get data into your app for UI or context? Use resources

        - Want to create predefined workflows for users? Use prompts

TDQS

B3.4/5.0

Scored across 2 tools

Disambiguation5/5

read_doc and edit_doc have clearly distinct purposes: one retrieves contentaren't and the other modifies it. There is no overlap or ambiguity between the two tools.

Naming Consistency5/5

Both tools follow the same verb_noun snake_case pattern: read_doc and edit_doc. The naming convention is perfectly consistent across the set.

Tool Count3/5

With only two tools, the server feels minimal and borderline thin for most use cases. However, for a narrowly scoped document read/edit utility, the count is not unreasonable.

Completeness2/5

The tool surface covers reading and editing but lacks create, delete, list, or search operations, preventing any real document lifecycle management. Agents cannot discover or create documents, which creates significant workflow gaps.

Maintenance

ActivityMaintained
ResponsivenessNo issues