This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Tutorials

Step-by-step guides to get you started with gomcptest

Tutorials are learning-oriented guides that take you through a series of steps to complete a project. They focus on learning by doing, and helping beginners get started with the system.

These tutorials will help you get familiar with gomcptest and its components.

1 - Getting Started with gomcptest

Get gomcptest up and running quickly with this beginner’s guide

This tutorial will guide you through setting up the gomcptest system and configuring Google Cloud authentication for the project.

What is gomcptest?

gomcptest is a proof of concept (POC) implementation of the Model Context Protocol (MCP) with a custom-built host. It enables AI models like Google’s Gemini to interact with their environment through a set of tools, creating powerful agentic systems.

Key Components

The project consists of three main parts:

  1. Host Components:

    • cliGCP: A command-line interface similar to Claude Code or ChatGPT, allowing direct interaction with AI models and tools
    • openaiserver: A server that implements the OpenAI API interface, enabling compatibility with existing OpenAI clients while using Google’s Vertex AI behind the scenes
  2. MCP Tools:

    • Bash: Execute shell commands
    • Edit/Replace: Modify file contents
    • GlobTool/GrepTool: Find files and search content
    • LS/View: Navigate and read the filesystem
    • dispatch_agent: Create sub-agents with specific tasks
  3. MCP Protocol: The standardized communication layer that allows models to discover, invoke, and receive results from tools

Use Cases

gomcptest enables a variety of agent-based applications:

  • Code assistance and pair programming
  • File system navigation and management
  • Data analysis and processing
  • Automated documentation
  • Custom domain-specific agents

Prerequisites

  • Go >= 1.21 installed on your system
  • Google Cloud account with access to Vertex AI API
  • Google Cloud CLI installed
  • Basic familiarity with terminal/command line

Setting up Google Cloud Authentication

Before using gomcptest with Google Cloud Platform services like Vertex AI, you need to set up your authentication.

1. Initialize the Google Cloud CLI

If you haven’t already configured the Google Cloud CLI, run:

gcloud init

This interactive command will guide you through:

  • Logging into your Google account
  • Selecting a Google Cloud project
  • Setting default configurations

2. Log in to Google Cloud

Authenticate your gcloud CLI with your Google account:

gcloud auth login

This will open a browser window where you can sign in to your Google account.

3. Set up Application Default Credentials (ADC)

Application Default Credentials are used by client libraries to automatically find credentials when connecting to Google Cloud services:

gcloud auth application-default login

This command will:

  1. Open a browser window for authentication
  2. Store your credentials locally (typically in ~/.config/gcloud/application_default_credentials.json)
  3. Configure your environment to use these credentials when accessing Google Cloud APIs

These credentials will be used by gomcptest when interacting with Google Cloud services.

Project Setup

  1. Clone the repository:

    git clone https://github.com/owulveryck/gomcptest.git
    cd gomcptest
    
  2. Build Tools: Compile all MCP-compatible tools

    make tools
    
  3. Choose Interface:

What’s Next

After completing the basic setup:

  • Explore the different tools in the tools directory
  • Try creating agent tasks with gomcptest
  • Check out the how-to guides for specific use cases

2 - Building Your First OpenAI-Compatible Server

Set up and run an OpenAI-compatible server with MCP tool support

This tutorial will guide you step-by-step through running and configuring the OpenAI-compatible server in gomcptest. By the end, you’ll have a working server that can communicate with LLM models and execute MCP tools.

Prerequisites

  • Go >= 1.21 installed
  • Access to Google Cloud Platform with Vertex AI API enabled
  • GCP authentication set up via gcloud auth login
  • Basic familiarity with terminal commands
  • The gomcptest repository cloned and tools built (see the Getting Started guide)

Step 1: Set Up Environment Variables

The OpenAI server requires several environment variables. Create a .envrc file in the host/openaiserver directory:

cd host/openaiserver
touch .envrc

Add the following content to the .envrc file, adjusting the values according to your setup:

# Server configuration
PORT=8080
LOG_LEVEL=INFO
IMAGE_DIR=/tmp/images

# GCP configuration
GCP_PROJECT=your-gcp-project-id
GCP_REGION=us-central1
GEMINI_MODELS=gemini-2.0-flash
IMAGEN_MODELS=imagen-3.0-generate-002

Ensure the image directory exists:

mkdir -p /tmp/images

Load the environment variables:

source .envrc

Step 2: Start the OpenAI Server

Now you can start the OpenAI-compatible server:

cd host/openaiserver
go run . -mcpservers "../bin/GlobTool;../bin/GrepTool;../bin/LS;../bin/View;../bin/Bash;../bin/Replace"

You should see output indicating that the server has started and registered the MCP tools.

Step 3: Test the Server with a Simple Request

Open a new terminal window and use curl to test the server:

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.0-flash",
    "messages": [
      {
        "role": "user",
        "content": "Hello, what can you do?"
      }
    ]
  }'

You should receive a response from the model explaining its capabilities.

Step 4: Test Function Calling

Now let’s test function calling by asking the model to list files in a directory:

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.0-flash",
    "messages": [
      {
        "role": "user",
        "content": "List the files in the current directory"
      }
    ]
  }'

The model should respond by calling the LS tool and returning the results.

What You’ve Learned

In this tutorial, you’ve:

  1. Set up the environment for the OpenAI-compatible server
  2. Built and registered MCP tools
  3. Started the server
  4. Tested basic chat completion
  5. Demonstrated function calling capabilities

Next Steps

Now that you have a working OpenAI-compatible server, you can:

  • Explore the API by sending different types of requests
  • Add custom tools to expand the server’s capabilities
  • Connect a client like the cliGCP to interact with the server
  • Experiment with different Gemini models

Check out the How to Configure the OpenAI Server guide for more advanced configuration options.

3 - Using the cliGCP Command Line Interface

Set up and use the cliGCP command line interface to interact with LLMs and MCP tools

This tutorial guides you through setting up and using the cliGCP command line interface to interact with LLMs and MCP tools. By the end, you’ll be able to run the CLI and perform basic tasks with it.

Prerequisites

  • Go >= 1.21 installed on your system
  • Access to Google Cloud Platform with Vertex AI API enabled
  • GCP authentication set up via gcloud auth login
  • The gomcptest repository cloned and tools built (see the Getting Started guide)

Step 1: Understand the cliGCP Tool

The cliGCP tool is a command-line interface similar to tools like Claude Code. It connects directly to the Google Cloud Platform’s Vertex AI API to access Gemini models and can use local MCP tools to perform actions on your system.

Step 2: Build the cliGCP Tool

First, build the cliGCP tool if you haven’t already:

cd gomcptest
make all  # This builds all tools including cliGCP

If you only want to build cliGCP, you can run:

cd host/cliGCP/cmd
go build -o ../../../bin/cliGCP

Step 3: Set Up Environment Variables

The cliGCP tool requires environment variables for GCP configuration. You can set these directly or create an .envrc file:

cd bin
touch .envrc

Add the following content to the .envrc file:

export GCP_PROJECT=your-gcp-project-id
export GCP_REGION=us-central1
export GEMINI_MODELS=gemini-2.0-flash
export IMAGEN_MODELS=imagen-3.0-generate-002
export IMAGE_DIR=/tmp/images

Load the environment variables:

source .envrc

Step 4: Run the cliGCP Tool

Now you can run the cliGCP tool with MCP tools:

cd bin
./cliGCP -mcpservers "./GlobTool;./GrepTool;./LS;./View;./dispatch_agent -glob-path ./GlobTool -grep-path ./GrepTool -ls-path ./LS -view-path ./View;./Bash;./Replace"

You should see a welcome message and a prompt where you can start interacting with the CLI.

Step 5: Simple Queries

Let’s try a few simple interactions:

> Hello, who are you?

You should get a response introducing the agent.

Step 6: Using Tools

Now let’s try using some of the MCP tools:

> List the files in the current directory

The CLI should call the LS tool and show you the files in the current directory.

> Search for files with "go" in the name

The CLI will use the GlobTool to find files matching that pattern.

> Read the README.md file

The CLI will use the View tool to show you the contents of the README.md file.

Step 7: Creating a Simple Task

Let’s create a simple task that combines multiple tools:

> Create a new file called test.txt with the text "Hello, world!" and then verify it exists

The CLI should:

  1. Use the Replace tool to create the file
  2. Use the LS tool to verify the file exists
  3. Use the View tool to show you the contents of the file

What You’ve Learned

In this tutorial, you’ve:

  1. Set up the cliGCP environment
  2. Run the CLI with MCP tools
  3. Performed basic interactions with the CLI
  4. Used various tools through the CLI to manipulate files
  5. Created a simple workflow combining multiple tools

Next Steps

Now that you’re familiar with the cliGCP tool, you can:

  • Explore more complex tasks that use multiple tools
  • Try using the dispatch_agent for more complex operations
  • Create custom tools and use them with the CLI
  • Experiment with different Gemini models

Check out the How to Configure the cliGCP Tool guide for advanced configuration options.