Skip to content

Commit ea012db

Browse files
google-labs-jules[bot]ba0f3
authored andcommitted
docs: create README.md and AGENTS.md
1 parent 64d1477 commit ea012db

File tree

2 files changed

+177
-1
lines changed

2 files changed

+177
-1
lines changed

AGENTS.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Agent Instructions for mcp-cli
2+
3+
This document provides instructions for AI agents working on the `mcp-cli` codebase.
4+
5+
## Project Overview
6+
7+
`mcp-cli` is a command-line tool for testing Model Context Protocol (MCP) servers. It's written in Go and uses `cobra` for the command-line interface and `bubbletea` for the terminal user interface (TUI).
8+
9+
The primary goal of this tool is to provide a user-friendly way to interact with MCP servers, select tools, provide arguments, and view results, all within the terminal.
10+
11+
## Tech Stack
12+
13+
- **Go:** The programming language used for the project.
14+
- **Cobra:** A library for creating powerful modern CLI applications in Go.
15+
- **Bubble Tea:** A framework for building terminal user interfaces. It follows The Elm Architecture (Model-View-Update).
16+
- **Lip Gloss:** A library for styling terminal output, used for the TUI layout.
17+
- **Bubbles:** A library of ready-to-use components for Bubble Tea applications (e.g., `list`, `textinput`, `viewport`).
18+
19+
## How to Build and Run
20+
21+
- **Build:** To build the executable, run:
22+
```sh
23+
go build
24+
```
25+
This will create an `mcp-cli` binary in the root directory.
26+
27+
- **Run:** The application has three main commands:
28+
- `mcp-cli stdio "<command>"`
29+
- `mcp-cli sse <url>`
30+
- `mcp-cli http <url>`
31+
32+
- **Debugging:** The `-v` or `--verbose` flag enables logging to a `debug.log` file. This is useful for debugging the TUI's behavior.
33+
34+
## Code Structure
35+
36+
All the application logic is contained in `main.go`.
37+
38+
### Key Components
39+
40+
- **`AppModel`:** This is the main struct that holds the state of the application. It includes the current view, the list of tools, the input fields, the debug log, and the viewport for the debug panel.
41+
42+
- **`initialModel`:** This function initializes the `AppModel` when the application starts.
43+
44+
- **`Update` function:** This is the heart of the Bubble Tea application. It handles all incoming messages (key presses, window resize events, tool results) and updates the model accordingly. It follows a switch-case structure to handle different message types and application states.
45+
46+
- **`View` function:** This function is responsible for rendering the TUI based on the current state of the `AppModel`. It uses `lipgloss` to create a two-column layout, with the main content on the left and the debug panel on the right.
47+
48+
- **`logf` function:** A helper function on `AppModel` to append messages to the debug log and update the debug viewport. Use this function for all logging that should be visible in the debug panel.
49+
50+
### TUI Views
51+
52+
The application has three main views, represented by the `viewState` enum:
53+
54+
1. `toolSelectionView`: The initial view that shows a list of available tools.
55+
2. `argumentInputView`: The view for entering arguments for a selected tool.
56+
3. `resultView`: The view for displaying the result of a tool call.
57+
58+
The debug panel is always visible on the right side of the screen.
59+
60+
## Development Workflow
61+
62+
1. **Understand the Request:** Carefully read the user's request and identify the required changes.
63+
2. **Explore the Code:** Use `read_file` to examine `main.go` and understand the current implementation.
64+
3. **Formulate a Plan:** Create a clear, step-by-step plan to implement the changes.
65+
4. **Implement Changes:** Use `replace_with_git_merge_diff` or other tools to modify the code.
66+
5. **Test:** After making changes, run `go build` to ensure the code compiles.
67+
6. **Review and Submit:** Use `request_code_review` to get feedback on your changes before submitting.
68+
69+
## Important Considerations
70+
71+
- **State Management:** The `AppModel` is the single source of truth for the application's state. All changes to the UI should be a result of changes to the `AppModel`.
72+
- **Pointer Receivers:** Methods on `AppModel` that modify its state (like `Update` and `logf`) must have a pointer receiver (`*AppModel`) to ensure the changes are applied to the original model.
73+
- **Command Handling:** The `Update` function returns a `tea.Cmd`, which represents a command to be executed by the Bubble Tea runtime (e.g., waiting for a tool result). Be sure to handle and batch commands correctly.
74+
- **Styling:** Use `lipgloss` for all TUI styling.
75+
- **Dependencies:** Use `go mod tidy` to manage dependencies.
76+
- **`.gitignore`:** The `mcp-cli` executable is ignored by `.gitignore`.

README.md

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,101 @@
1-
# mcpc
1+
# MCP-CLI
2+
3+
MCP-CLI is a command-line tool for interacting with and testing Model Context Protocol (MCP) servers. It provides a user-friendly terminal user interface (TUI) for selecting and executing tools offered by an MCP server.
4+
5+
## Features
6+
7+
- **Multiple Transports:** Connect to MCP servers using `stdio`, `sse` (Server-Sent Events), or `http` (streamable HTTP).
8+
- **Interactive TUI:** A terminal user interface built with `bubbletea` that allows you to:
9+
- Select a tool from a list of available tools.
10+
- Enter arguments for the selected tool in a form.
11+
- View the results of the tool execution.
12+
- **Debug Panel:** A scrollable debug panel on the right side of the TUI that shows:
13+
- Informational logs (key presses, state changes).
14+
- The arguments sent to the tool in a pretty-printed JSON format.
15+
- The results of tool calls.
16+
- **Verbose Logging:** Use the `-v` flag to enable verbose logging to a `debug.log` file for troubleshooting.
17+
18+
## Installation
19+
20+
You can install `mcp-cli` using `go install`:
21+
22+
```sh
23+
go install mcp-cli
24+
```
25+
26+
Alternatively, you can build it from source.
27+
28+
## Building from Source
29+
30+
1. Clone the repository:
31+
```sh
32+
git clone <repository-url>
33+
cd mcp-cli
34+
```
35+
2. Build the executable:
36+
```sh
37+
go build
38+
```
39+
This will create an `mcp-cli` executable in the current directory.
40+
41+
## Usage
42+
43+
The `mcp-cli` tool has three main commands, one for each transport protocol.
44+
45+
### `stdio`
46+
47+
Connect to an MCP server that communicates over standard input/output.
48+
49+
```sh
50+
mcp-cli stdio "<command-to-start-server>"
51+
```
52+
53+
**Example:**
54+
55+
```sh
56+
mcp-cli stdio "python /path/to/mcp/server.py"
57+
```
58+
59+
### `sse`
60+
61+
Connect to an MCP server that uses Server-Sent Events (SSE).
62+
63+
```sh
64+
mcp-cli sse <server-url>
65+
```
66+
67+
**Example:**
68+
69+
```sh
70+
mcp-cli sse http://localhost:8080/mcp
71+
```
72+
73+
### `http`
74+
75+
Connect to an MCP server that uses streamable HTTP.
76+
77+
```sh
78+
mcp-cli http <server-url>
79+
```
80+
81+
**Example:**
82+
83+
```sh
84+
mcp-cli http http://localhost:8080/mcp
85+
```
86+
87+
### Global Flags
88+
89+
- `-v`, `--verbose`: Enable verbose logging to `debug.log`.
90+
91+
## TUI Guide
92+
93+
When you connect to an MCP server, you will be presented with a terminal user interface.
94+
95+
- **Tool Selection View:** A list of available tools. Use the arrow keys to navigate and press `Enter` to select a tool.
96+
- **Argument Input View:** A form for entering the arguments for the selected tool. Use `Tab` to switch between fields and `Enter` to submit the tool call.
97+
- **Result View:** Shows the result of the tool execution. Press `Enter` to return to the argument input view for the same tool, allowing you to easily call it again with different arguments.
98+
- **Debug Panel:** The right-hand panel shows a scrollable log of events, tool calls, and results. Use the up and down arrow keys to scroll through the log.
99+
- **Navigation:**
100+
- `Esc`: Return to the tool selection view.
101+
- `Ctrl+C`: Exit the application.

0 commit comments

Comments
 (0)