# MCP Server

J-Quants API's official MCP server is optimized for Generative AI to correctly use the J-Quants API.
By introducing the MCP Server, you can easily access J-Quants data by entrusting code generation to AI.
This guide provides steps to introduce the J-Quants official MCP Server to your AI client.

## Overall Flow

1. **Check Prerequisites**: Ensure Python 3.10 or higher and uv are installed.
2. **Install MCP Server**: Install the MCP Server using the uvx command.
3. **Configure AI Client**: Register the MCP Server in Claude Desktop or Cursor.
4. **Start Using**: Just ask the AI to get J-Quants API endpoint information and sample code.

## Prerequisites

The following environment is required to use the MCP Server.

- **Python 3.10 or higher**
- **[uv](https://github.com/astral-sh/uv)** (Recommended) or pip

> **Note**
>
> - uv is a fast Python package manager. If you haven't installed it yet, you can install it with the following command.

```bash {{ title: "macOS / Linux" }}
curl -LsSf https://astral.sh/uv/install.sh | sh
```

```bash {{ title: "Windows (PowerShell)" }}
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

## Installation

Install the MCP Server with the following command.
We recommend using `uv tool`, but you can also install it with `pip`.

```bash {{ title: "uv tool (Recommended)" }}
# Install directly from GitHub
uv tool install git+https://github.com/J-Quants/j-quants-doc-mcp.git

# Or clone locally and install
git clone https://github.com/J-Quants/j-quants-doc-mcp.git
cd j-quants-doc-mcp
uv tool install .
```

```bash {{ title: "pip" }}
# Install directly from GitHub
pip install git+https://github.com/J-Quants/j-quants-doc-mcp.git

# Or clone locally and install
git clone https://github.com/J-Quants/j-quants-doc-mcp.git
cd j-quants-doc-mcp
pip install .
```

[View GitHub Repository →](https://github.com/J-Quants/j-quants-doc-mcp)

## Configuration for AI Client

### Claude Desktop

Add the following to `claude_desktop_config.json`.

```json {{ title: "If installed with uv tool" }}
{
  "mcpServers": {
    "j-quants-doc-mcp": {
      "command": "uvx",
      "args": ["j-quants-doc-mcp"]
    }
  }
}
```

```json {{ title: "If installed with pip" }}
{
  "mcpServers": {
    "j-quants-doc-mcp": {
      "command": "j-quants-doc-mcp",
      "args": []
    }
  }
}
```

**Config File Location:**

- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

### Cursor

1. Open the menu bar "Cursor" -> "Preferences" -> "Cursor Settings".
2. Select "Tools & MCP" from the left menu and click "New MCP Server".
3. Add the following to the opened JSON file (`mcp.json`).

```json {{ title: "If installed with uv tool" }}
{
  "mcpServers": {
    "j-quants-doc-mcp": {
      "command": "uvx",
      "args": ["j-quants-doc-mcp"]
    }
  }
}
```

```json {{ title: "If installed with pip" }}
{
  "mcpServers": {
    "j-quants-doc-mcp": {
      "command": "j-quants-doc-mcp",
      "args": []
    }
  }
}
```

**Config File Location:**

- macOS: `~/.cursor/mcp.json`
- Windows: `%USERPROFILE%\.cursor\mcp.json`

> **Note**
>
> - After configuration, please restart your AI client. Once the MCP Server is correctly recognized, the AI will be able to answer questions about the J-Quants API.

## Update

If you have already installed it, you can update to the latest version using the following methods.

```bash {{ title: "If using uv tool" }}
# If installed directly from GitHub
uv tool upgrade j-quants-doc-mcp

# If installed from local clone
cd j-quants-doc-mcp
git pull
uv tool upgrade j-quants-doc-mcp
```

```bash {{ title: "If using pip" }}
# If installed directly from GitHub
pip install --upgrade git+https://github.com/J-Quants/j-quants-doc-mcp.git

# If installed from local clone
cd j-quants-doc-mcp
git pull
pip install --upgrade .
```

> **Note**
>
> - After updating, restart Claude Desktop or Cursor to reflect the new version.

## Troubleshooting

### Not recognized by Claude Desktop or Cursor

1. Check if the JSON in the configuration file is in the correct format.
2. Restart the AI Client (Claude Desktop / Cursor).

### Generated code cannot be executed

To execute the generated Python code, please install the following dependencies.

```bash {{ title: "Install Dependencies" }}
pip install httpx python-dotenv
```

> **Note**
>
> - Check if the environment variables are correctly set.
