infobip_mcp

package module
v0.0.0-...-8975553 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 14 Imported by: 0

README

xk6-infobip-mcp

k6 extension for Model Context Protocol (MCP) integration

This k6 extension enables performance testing of MCP (Model Context Protocol) servers by providing a JavaScript API for creating MCP clients, calling tools, and managing connections. It is ideal for load testing MCP-based applications and validating MCP server performance under various conditions.

Originally developed to load test Infobip MCP Servers, this extension works with any MCP-compliant server implementation.

Example

import mcp from "k6/x/infobip_mcp";

export const options = {
  vus: 10,
  duration: '30s',
};

export default function () {
  // Create MCP client
  const client = mcp.NewClient({
    endpoint: "https://your-mcp-server.com/mcp",
    timeout: 30,
    isSSE: false,
    headers: {
      "Authorization": "Bearer your-token",
      "Content-Type": "application/json"
    }
  });

  // Call a tool on the MCP server
  const result = client.callTool("your_tool_name", {
    param1: "value1",
    param2: 42
  });

  console.log("Tool response:", result);

  // Clean up connection
  client.closeConnection();
}

Quick Start

  1. Build a custom k6 binary with xk6-infobip-mcp
    Use xk6 to build k6 with this extension:

    go install go.k6.io/xk6/cmd/xk6@latest
    xk6 build --with github.com/infobip/xk6-infobip-mcp
    
  2. Write your test script
    Use the example above or create your own test script script.js.

  3. Run your test
    Use your custom k6 binary to run the script:

    ./k6 run script.js
    

API Reference

NewClient(config)

Creates a new MCP client instance.

Parameters:

  • config.endpoint (string): MCP server endpoint URL
  • config.timeout (number): Connection timeout in seconds used for connection and tool call
  • config.isSSE (boolean): Use Server-Sent Events transport
  • config.headers (object, optional): Custom HTTP headers

Returns: MCPClient instance

MCPClient.callTool(toolName, args)

Calls a tool on the MCP server.

Parameters:

  • toolName (string): Name of the tool to call
  • args (object): Arguments to pass to the tool

Returns: Tool response as a string

MCPClient.closeConnection()

Closes the MCP client connection.

Metrics

MCP-Specific Metrics
Metric Name Type Description
mcp_call_duration Trend Duration of individual MCP tool calls in milliseconds. Use this to analyze response times and identify slow operations.
mcp_calls Counter Total number of MCP tool calls made during the test. Helps track the volume of operations executed.
mcp_success Rate Success rate of MCP operations in percentage. A high rate indicates reliable server performance.
mcp_errors Rate Error rate of MCP operations in percentage. Monitor this to identify reliability issues with your MCP server.
HTTP Metrics

Since MCP communication happens over HTTP, standard k6 HTTP metrics are also collected:

Metric Name Type Description
http_req_duration Trend Duration of HTTP requests to the MCP server in milliseconds. Includes connection time, sending, waiting, and receiving.
http_reqs Counter Total number of HTTP requests made to the MCP server. Each MCP operation typically results in one or more HTTP requests.
http_req_failed Rate Rate of failed HTTP requests in percentage (status codes ≥ 400). Note: Some specific status codes may not be considered failures (e.g., 404 for DELETE, 405 for GET).
Metric Tags

All metrics include the following tags for detailed analysis:

  • method: HTTP method used (GET, POST, etc.)
  • url: The MCP server endpoint URL
  • status: HTTP response status code

Contribute

If you wish to contribute to this project, please start by reading the Contributing Guidelines.

Documentation

Overview

Package infobip_mcp contains the xk6-infobip-mcp extension.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	Endpoint string
	Timeout  int64
	IsSSE    bool
	Headers  map[string]string
}

type MCPClient

type MCPClient struct {
	// contains filtered or unexported fields
}

func (*MCPClient) CallTool

func (client *MCPClient) CallTool(toolName string, args map[string]any, rt *sobek.Runtime) string

CallTool invokes a named tool through the MCP protocol with the provided arguments.

func (*MCPClient) CloseConnection

func (client *MCPClient) CloseConnection() error

CloseConnection terminates the MCP client session and cleans up resources.

type MCPMetrics

type MCPMetrics struct {
	// MCP metrics
	MCPCallDuration *metrics.Metric
	MCPCalls        *metrics.Metric
	MCPSuccess      *metrics.Metric
	MCPErrors       *metrics.Metric

	// HTTP metrics
	HTTPRequestDuration *metrics.Metric
	HTTPRequestCount    *metrics.Metric
	HTTPRequestErrors   *metrics.Metric
	HTTPRequestSize     *metrics.Metric

	TagsAndMeta *metrics.TagsAndMeta
}

type RoundTripper

type RoundTripper struct {
	// contains filtered or unexported fields
}

func (RoundTripper) RoundTrip

func (r RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface. It intercepts HTTP requests to add custom headers and collect detailed metrics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL