HTTP Server API Reference

Complete reference for RMCP HTTP server endpoints and statistical tools.

🌐 Live Server: https://rmcp-server-394229601724.us-central1.run.app

πŸ” Interactive Docs: https://rmcp-server-394229601724.us-central1.run.app/docs

Core Endpoints

Root Endpoint

MCP Protocol Endpoint

Server-Sent Events

Health Check

Session Management

All MCP communication requires session initialization and proper header management.

Initialize Session

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-06-18",
    "capabilities": {},
    "clientInfo": {
      "name": "my-client",
      "version": "1.0"
    }
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2025-06-18",
    "capabilities": {
      "tools": {"listChanged": false},
      "resources": {"subscribe": true, "listChanged": true},
      "prompts": {"listChanged": false},
      "logging": {},
      "completion": {}
    },
    "serverInfo": {
      "name": "RMCP MCP Server",
      "version": "0.7.0"
    }
  }
}

Response Headers: - Mcp-Session-Id: <generated-session-id> - Use in subsequent requests

Statistical Analysis Tools

List Tools

Request:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list",
  "params": {}
}

Response: List of 53 statistical analysis tools across 11 categories.

Call Tools

Request:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "<tool_name>",
    "arguments": { ... }
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Statistical analysis results..."
      },
      {
        "type": "image",
        "data": "base64-encoded-image",
        "mimeType": "image/png"
      }
    ]
  }
}

Regression Analysis Tools

linear_model

Linear and logistic regression analysis with comprehensive diagnostics.

Arguments:

Parameter

Type

Description

formula

string

R formula (e.g., β€œy ~ x1 + x2”)

data

string

Data in CSV format or array

format

string

Data format: β€œcsv”, β€œjson”, or β€œarray”

family

string

β€œgaussian” (linear) or β€œbinomial” (logistic)

include_plots

boolean

Generate diagnostic plots (default: true)

Example:

{
  "name": "linear_model",
  "arguments": {
    "formula": "sales ~ marketing + season",
    "data": "sales,marketing,season\n100,5,1\n120,8,2\n115,6,1\n140,10,2",
    "format": "csv",
    "family": "gaussian"
  }
}

Returns: Model summary, coefficients, RΒ², diagnostics, and residual plots.

correlation_analysis

Correlation matrices with significance testing and confidence intervals.

Arguments:

Example:

{
  "name": "correlation_analysis",
  "arguments": {
    "data": {
      "sales": [100, 120, 115, 140],
      "marketing": [5, 8, 6, 10],
      "satisfaction": [7.5, 8.2, 7.8, 8.9]
    },
    "format": "json",
    "method": "pearson"
  }
}

Returns: Correlation matrix, p-values, confidence intervals, and heatmap.

Time Series Analysis Tools

time_series_arima

ARIMA modeling with automatic order selection and forecasting.

Arguments:

Example:

{
  "name": "time_series_arima",
  "arguments": {
    "data": [100, 105, 110, 108, 115, 120, 125, 130, 128, 135],
    "variable_name": "monthly_sales",
    "forecast_periods": 3,
    "auto_arima": true
  }
}

Returns: ARIMA model summary, forecasts with confidence intervals, and diagnostic plots.

Statistical Testing Tools

t_test

One-sample, two-sample, and paired t-tests with effect sizes.

Arguments:

Example:

{
  "name": "t_test",
  "arguments": {
    "data1": [23, 25, 27, 24, 26, 28, 25, 24],
    "data2": [20, 22, 24, 21, 23, 25, 22, 21],
    "test_type": "two_sample",
    "alternative": "two_sided"
  }
}

Returns: T-statistic, p-value, confidence interval, and effect size.

Machine Learning Tools

kmeans_clustering

K-means clustering with optimal cluster selection and visualization.

Arguments:

Parameter

Type

Description

data

mixed

Data matrix in CSV format or arrays

format

string

Data format: β€œcsv”, β€œjson”, or β€œarray”

k

number

Number of clusters (optional - auto-selects)

max_k

number

Maximum clusters to test (default: 10)

include_plots

boolean

Generate cluster visualization (default: true)

Example:

{
  "name": "kmeans_clustering",
  "arguments": {
    "data": "x,y\n1,2\n2,3\n8,9\n9,8\n1,1\n9,9",
    "format": "csv",
    "k": 2
  }
}

Returns: Cluster assignments, centroids, within-cluster sum of squares, and visualization.

Data Analysis Tools

descriptive_stats

Comprehensive descriptive statistics with distribution analysis.

Arguments:

Example:

{
  "name": "descriptive_stats",
  "arguments": {
    "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    "variable_name": "test_scores",
    "include_plots": true
  }
}

Returns: Mean, median, standard deviation, quartiles, skewness, kurtosis, and plots.

Visualization Tools

scatter_plot

Professional scatter plots with trend lines and statistical annotations.

Arguments:

Parameter

Type

Description

x

array

X-axis values

y

array

Y-axis values

x_name

string

X-axis label

y_name

string

Y-axis label

add_trend_line

boolean

Add linear trend line (default: true)

add_confidence

boolean

Add confidence bands (default: true)

color_by

array

Optional grouping variable

Example:

{
  "name": "scatter_plot",
  "arguments": {
    "x": [1, 2, 3, 4, 5],
    "y": [2, 4, 6, 8, 10],
    "x_name": "Marketing Spend",
    "y_name": "Sales Revenue",
    "add_trend_line": true
  }
}

Returns: Professional scatter plot with correlation statistics.

Error Handling

JSON-RPC 2.0 Error Codes

Standard JSON-RPC error responses:

Code

Description

-32700

Parse error - Invalid JSON

-32600

Invalid Request - JSON-RPC format error

-32601

Method not found - Unknown method

-32602

Invalid params - Parameter validation error

-32603

Internal error - Server processing error

HTTP Error Codes

HTTP-specific errors:

Code

Description

400

Bad Request - Missing headers/invalid format

405

Method Not Allowed - Wrong HTTP method

500

Internal Server Error - Unexpected error

Example Error Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "400: Session not initialized. Send initialize request first.",
    "data": {"type": "HTTPException"}
  }
}

Rate Limiting

The server implements reasonable rate limiting for stability:

  • Concurrent Sessions: 100 active sessions

  • Request Rate: 60 requests per minute per session

  • Tool Execution: 10 concurrent tool executions per session

Exceeding limits returns HTTP 429 (Too Many Requests).

Security

Protocol Security: - MCP protocol version validation - Session-based access control - Request origin validation

Data Security: - R code execution in sandboxed environment - File system access restrictions - Package installation approval system

Transport Security: - HTTPS encryption for data in transit - CORS policy for browser access - Standard HTTP security headers

Best Practices

Client Implementation

  1. Session Management: Always initialize sessions and handle session IDs properly

  2. Error Handling: Implement robust error handling for network and protocol errors

  3. Timeout Handling: Set appropriate timeouts for long-running statistical operations

  4. Connection Pooling: Reuse HTTP connections for better performance

Data Formats

  1. CSV Format: Best for tabular data with headers

  2. JSON Format: Best for structured data with mixed types

  3. Array Format: Best for simple numeric vectors

Performance Tips

  1. Batch Operations: Group related analysis calls when possible

  2. Data Size: Keep datasets reasonable (<10MB) for optimal performance

  3. Visualization: Disable plots for large batch operations if not needed

  4. SSE Monitoring: Use Server-Sent Events for long-running operations

Integration Examples

See HTTP Server Getting Started Guide for complete client implementation examples in:

  • Python with requests library

  • JavaScript with fetch API

  • curl command-line examples

πŸ”— Additional Resources: