gojiplus rmcp

gojiplus rmcp avatar

by gojiplus

R MCP Server

What is gojiplus rmcp

R MCP Server

PyPI version Downloads License: MIT

A Model Context Protocol (MCP) server that provides advanced econometric modeling and data analysis capabilities through R. This server enables AI assistants to perform sophisticated econometric and statistical analyses seamlessly, helping you quickly gain insights from your data.

Features

  • Linear Regression: Run linear models with optional robust standard errors.
  • Panel Data Analysis: Estimate fixed effects, random effects, pooling, between, and first-difference models.
  • Instrumental Variables: Build and estimate IV regression models.
  • Diagnostic Tests: Assess heteroskedasticity, autocorrelation, and model misspecification.
  • Descriptive Statistics: Generate summary statistics for datasets using R’s summary() functionality.
  • Correlation Analysis: Compute Pearson or Spearman correlations between variables.
  • Group-By Aggregations: Group data by specified columns and compute summary statistics using dplyr.
  • Resources: Access reference documentation for various econometric techniques.
  • Prompts: Use pre-defined prompt templates for common econometric analyses.

Installation

Using Docker (Recommended)

  1. Build the Docker image:

    docker build -t r-econometrics-mcp .
    
  2. Run the container:

docker run -it r-econometrics-mcp

Manual Installation

Install the required Python packages:

pip install -r requirements.txt

Install the required R packages (if you run the server outside a container):

install.packages(c("plm", "lmtest", "sandwich", "AER", "jsonlite"), repos="https://cloud.r-project.org/")

Run the server:

python rmcp.py

Usage

The server communicates via standard input/output. When you run:

python rmcp.py

it starts and waits for JSON messages on standard input. To test the server manually, create a file (for example, test_request.json) with a compact (single-line) JSON message.

Example Test

Create test_request.json with the following content (a one-line JSON):

{"tool": "linear_model", "args": {"formula": "y ~ x1", "data": {"x1": [1,2,3,4,5], "y": [1,3,5,7,9]}, "robust": false}}

Then run:

cat test_request.json | python rmcp.py

Output

{"coefficients": {"(Intercept)": -1, "x1": 2}, "std_errors": {"(Intercept)": 2.8408e-16, "x1": 8.5654e-17}, "t_values": {"(Intercept)": -3520120717017444, "x1": 23349839270207356}, "p_values": {"(Intercept)": 5.0559e-47, "x1": 1.7323e-49}, "r_squared": 1, "adj_r_squared": 1, "sigma": 2.7086e-16, "df": [2, 3, 2], "model_call": "lm(formula = formula, data = data)", "robust": false}

Usage with Claude Desktop

  1. Launch Claude Desktop
  2. Open the MCP Servers panel
  3. Add a new server with the following configuration:
    • Name: R Econometrics
    • Transport: stdio
    • Command: path/to/python r_econometrics_mcp.py
    • (Or if using Docker): docker run -i r-econometrics-mcp

Example Queries

Here are some example queries you can use with Claude once the server is connected:

Linear Regression

Can you analyze the relationship between price and mpg in the mtcars dataset using linear regression?

Panel Data Analysis

I have panel data with variables gdp, investment, and trade for 30 countries over 20 years. Can you help me determine if a fixed effects or random effects model is more appropriate?

Instrumental Variables

I'm trying to estimate the causal effect of education on wages, but I'm concerned about endogeneity. Can you help me set up an instrumental variables regression?

Diagnostic Tests

After running my regression model, I'm concerned about heteroskedasticity. Can you run appropriate diagnostic tests and suggest corrections if needed?

Tools Reference

linear_model

Run a linear regression model.

Parameters:

  • formula (string): The regression formula (e.g., 'y ~ x1 + x2')
  • data (object): Dataset as a dictionary/JSON object
  • robust (boolean, optional): Whether to use robust standard errors

panel_model

Run a panel data model.

Parameters:

  • formula (string): The regression formula (e.g., 'y ~ x1 + x2')
  • data (object): Dataset as a dictionary/JSON object
  • index (array): Panel index variables (e.g., ['individual', 'time'])
  • effect (string, optional): Type of effects: 'individual', 'time', or 'twoways'
  • model (string, optional): Model type: 'within', 'random', 'pooling', 'between', or 'fd'

diagnostics

Perform model diagnostics.

Parameters:

  • formula (string): The regression formula (e.g., 'y ~ x1 + x2')
  • data (object): Dataset as a dictionary/JSON object
  • tests (array): Tests to run (e.g., ['bp', 'reset', 'dw'])

iv_regression

Estimate instrumental variables regression.

Parameters:

  • formula (string): The regression formula (e.g., 'y ~ x1 + x2 | z1 + z2')
  • data (object): Dataset as a dictionary/JSON object

Resources

  • econometrics:formulas: Information about common econometric model formulations
  • econometrics:diagnostics: Reference for diagnostic tests
  • econometrics:panel_data: Guide to panel data analysis in R

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Leave a Comment

Frequently Asked Questions

What is MCP?

MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.

What are MCP Servers?

MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.

How do MCP Servers work?

MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.

Are MCP Servers secure?

Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.

Related MCP Servers

chrisdoc hevy mcp avatar

chrisdoc hevy mcp

mcp
sylphlab pdf reader mcp avatar

sylphlab pdf reader mcp

An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.

pdf-parsetypescriptnodejs
aashari mcp server atlassian bitbucket avatar

aashari mcp server atlassian bitbucket

Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.

atlassianrepositorymcp
aashari mcp server atlassian confluence avatar

aashari mcp server atlassian confluence

Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.

atlassianmcpconfluence
prisma prisma avatar

prisma prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

cockroachdbgomcp
Zzzccs123 mcp sentry avatar

Zzzccs123 mcp sentry

mcp sentry for typescript sdk

mcptypescript
zhuzhoulin dify mcp server avatar

zhuzhoulin dify mcp server

mcp
zhongmingyuan mcp my mac avatar

zhongmingyuan mcp my mac

mcp
zhixiaoqiang desktop image manager mcp avatar

zhixiaoqiang desktop image manager mcp

MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)

mcp
zhixiaoqiang antd components mcp avatar

zhixiaoqiang antd components mcp

An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询

designantdapi

Submit Your MCP Server

Share your MCP server with the community

Submit Now