Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions aichat/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Environment template - copy to .env and fill in your values
# Get your API token from https://platform.acedata.cloud

# AceDataCloud API Configuration (REQUIRED)
ACEDATACLOUD_API_TOKEN=your_api_token_here
ACEDATACLOUD_API_BASE_URL=https://api.acedata.cloud

# AIChat Configuration (Optional)
AICHAT_REQUEST_TIMEOUT=60

# MCP Server Configuration (Optional)
MCP_SERVER_NAME=aichat
MCP_TRANSPORT=stdio

# Logging (Optional)
LOG_LEVEL=INFO
82 changes: 82 additions & 0 deletions aichat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# Ruff
.ruff_cache/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# OS
.DS_Store
Thumbs.db

# Project specific
*.log
1 change: 1 addition & 0 deletions aichat/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
38 changes: 38 additions & 0 deletions aichat/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target-version = "py310"
line-length = 100
exclude = [
".git",
".ruff_cache",
".venv",
"__pycache__",
"build",
"dist",
]

[format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"ARG", # flake8-unused-arguments
"SIM", # flake8-simplify
]
ignore = [
"E501", # line too long (handled by formatter)
"B008", # do not perform function calls in argument defaults
"E402", # module level import not at top of file (needed for dotenv loading)
]

[lint.isort]
known-first-party = ["core", "tools", "prompts"]

18 changes: 18 additions & 0 deletions aichat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2026.1.0.1] - 2026-04-25

### Added
- Initial release of MCP AIChat server
- AI conversation tool supporting 70+ models
- Support for GPT-5, GPT-4, o-series, DeepSeek, Grok, and GLM models
- Stateful conversation mode for multi-turn dialogues
- Reference URLs support for context-aware responses
- Model listing tool with detailed descriptions
- Usage guide tool
- OAuth 2.1 support for remote HTTP mode
40 changes: 40 additions & 0 deletions aichat/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# AIChatMCP

MCP (Model Context Protocol) server for AI Dialogue via AceDataCloud API.

## Project Structure

```
core/
config.py — Settings dataclass (API token, base URL)
server.py — FastMCP server singleton
client.py — httpx async HTTP client
types.py — Literal types (ChatModel, etc.)
exceptions.py — Error classes (AuthError, APIError, TimeoutError)
tools/
chat_tools.py — aichat conversation
info_tools.py — list models, usage guide
prompts/ — LLM guidance prompts
tests/ — pytest-asyncio tests
```

## Sync from Docs

When invoked by the sync workflow, the Docs repo is checked out at `_docs/`. Your job:

1. **Source of truth** — `_docs/openapi/aichat.json` is the OpenAPI spec for the AIChat API.
2. **Compare models** — The Literal types in `core/types.py` must match the spec's model enum. Add/remove as needed.
3. **Compare parameters** — Each `@mcp.tool()` function's parameters should match the corresponding OpenAPI endpoint.
4. **Update defaults** — If a new model becomes the recommended default, update the default in `core/types.py`.
5. **Update README** — Keep the model table and feature list current.
6. **Add tests** — For new tools or parameters, add test cases in `tests/`.
7. **PR title** — Use format: `sync: <description> [auto-sync]`

## Development

```bash
pip install -e ".[dev]"
pytest --cov=core --cov=tools
ruff check .
```

9 changes: 9 additions & 0 deletions aichat/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.12-slim

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir .

CMD ["mcp-aichat", "--transport", "http", "--port", "8000"]
21 changes: 21 additions & 0 deletions aichat/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 AceDataCloud

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
93 changes: 93 additions & 0 deletions aichat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# AIChatMCP

<!-- mcp-name: io.github.AceDataCloud/mcp-aichat -->

[![PyPI version](https://img.shields.io/pypi/v/mcp-aichat.svg)](https://pypi.org/project/mcp-aichat/)
[![PyPI downloads](https://img.shields.io/pypi/dm/mcp-aichat.svg)](https://pypi.org/project/mcp-aichat/)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![MCP](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io)

A [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for AI dialogue using the [AIChat API](https://platform.acedata.cloud) through the [AceDataCloud API](https://platform.acedata.cloud).

Access 70+ AI models including GPT-5, GPT-4, o-series, DeepSeek, Grok, and GLM directly from Claude, VS Code, or any MCP-compatible client.

## Features

- **Multi-Model Support** - Access GPT-5, GPT-4, o-series, DeepSeek, Grok, GLM, and more
- **Stateful Conversations** - Multi-turn dialogue with conversation memory
- **Reference Support** - Provide URLs as context for model responses
- **Preset Configurations** - Use preset model configurations
- **Model Listing** - Browse all available models with descriptions

## Tool Reference

| Tool | Description |
|------|-------------|
| `aichat_conversation` | Send a question to an AI model and get an answer. |
| `aichat_list_models` | List all available AI chat models. |
| `aichat_get_usage_guide` | Get a comprehensive guide for using the AIChat tools. |

## Quick Start

### 1. Get Your API Token

1. Sign up at [AceDataCloud Platform](https://platform.acedata.cloud)
2. Go to the API documentation page
3. Click **"Acquire"** to get your API token
4. Copy the token for use below

### 2. Install and Configure

```bash
# Install with pip
pip install mcp-aichat

# Or use with uvx (no installation needed)
uvx mcp-aichat
```

### 3. Add to Claude Desktop

Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
"mcpServers": {
"aichat": {
"command": "uvx",
"args": ["mcp-aichat"],
"env": {
"ACEDATACLOUD_API_TOKEN": "your_token_here"
}
}
}
}
```

## Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `ACEDATACLOUD_API_TOKEN` | Yes | - | API token from AceDataCloud |
| `ACEDATACLOUD_API_BASE_URL` | No | `https://api.acedata.cloud` | API base URL |
| `AICHAT_REQUEST_TIMEOUT` | No | `60` | Request timeout in seconds |
| `MCP_SERVER_NAME` | No | `aichat` | MCP server name |
| `LOG_LEVEL` | No | `INFO` | Logging level |

## Available Models

The AIChat API supports 70+ models including:

- **GPT-5 Series**: gpt-5.5, gpt-5.5-pro, gpt-5.4, gpt-5.2, gpt-5.1, gpt-5, gpt-5-mini, gpt-5-nano
- **GPT-4 Series**: gpt-4.1, gpt-4o, gpt-4o-mini, gpt-4, gpt-4-turbo, and dated variants
- **o-series**: o1, o1-mini, o1-pro, o3, o3-mini, o3-pro, o4-mini, and variants
- **DeepSeek**: deepseek-r1, deepseek-r1-0528, deepseek-v3, deepseek-v3-250324
- **Grok**: grok-3
- **GLM**: glm-5.1, glm-4.7, glm-4.6, glm-4.5-air, glm-3-turbo

Use `aichat_list_models` to see the full list.

## License

MIT License - see [LICENSE](LICENSE) file for details.
15 changes: 15 additions & 0 deletions aichat/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Core module for MCP AIChat server."""

from core.client import AIChatClient
from core.config import settings
from core.exceptions import AIChatAPIError, AIChatAuthError, AIChatValidationError
from core.server import mcp

__all__ = [
"AIChatClient",
"settings",
"mcp",
"AIChatAPIError",
"AIChatAuthError",
"AIChatValidationError",
]
Loading