Skip to content

Commit e7d804d

Browse files
authored
Merge pull request #103 from him0/refactor/remove-api-mode
refactor: remove API mode, keep client mode only
2 parents 4dbbc96 + a3368ae commit e7d804d

11 files changed

Lines changed: 44 additions & 974 deletions

File tree

.changeset/remove-api-mode.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@him0/freee-mcp": minor
3+
---
4+
5+
Remove API mode, keep client mode only
6+
7+
BREAKING CHANGE: `freee-mcp api` subcommand has been removed. The server now only operates in client mode (HTTP method sub-commands). Use `freee-mcp` or `freee-mcp client` to start the server.

.github/workflows/claude.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
# assignee_trigger: "claude-bot"
6060

6161
# Optional: Allow Claude to run specific commands
62-
allowed_tools: '"Bash(ls:*)",Bash(pnpm install),Bash(pnpm type-check),Bash(pnpm test:*),Bash(pnpm lint),Bash(pnpm format),Bash(pnpm build)'
62+
allowed_tools: '"Bash(ls:*)",Bash(pnpm install),Bash(pnpm typecheck),Bash(pnpm test:*),Bash(pnpm lint),Bash(pnpm format),Bash(pnpm build)'
6363

6464
# Optional: Add custom instructions for Claude to customize its behavior for your project
6565
# custom_instructions: |

CLAUDE.md

Lines changed: 13 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
- `pnpm dev` - Start development server with watch mode
88
- `pnpm build` - Full build (types + esbuild)
9-
- `pnpm type-check` - TypeScript type checking
9+
- `pnpm typecheck` - TypeScript type checking
1010
- `pnpm lint` - Run ESLint
1111
- `pnpm inspector` - MCP inspector for debugging tools
1212
- `node scripts/test-tools.js` - Quick tool verification
@@ -26,25 +26,19 @@ MCP server that exposes freee API endpoints as MCP tools:
2626
- `pm-api-schema.json` - 工数管理API (https://api.freee.co.jp/pm)
2727
- `sm-api-schema.json` - 販売API (https://api.freee.co.jp/sm)
2828
- **Schema Loader**: `src/openapi/schema-loader.ts` loads and manages all API schemas
29-
- **Tool Generation**: Two modes available (selected via CLI subcommand):
30-
- **Client Mode** (`freee-mcp client`): Sub-command tools per HTTP method **[RECOMMENDED]**
31-
- `generateClientModeTool()` in `src/openapi/client-mode.ts` creates method-specific tools
32-
- Tools: `freee_api_get`, `freee_api_post`, `freee_api_put`, `freee_api_delete`, `freee_api_patch`, `freee_api_list_paths`
33-
- Automatically detects API type from path and uses correct base URL
34-
- Validates paths against all OpenAPI schemas before execution
35-
- Reduces context window usage significantly (6 tools vs hundreds)
36-
- Supports all 5 freee APIs seamlessly
37-
- **Individual Mode** (`freee-mcp api` or default): One tool per endpoint
38-
- `generateToolsFromOpenApi()` in `src/openapi/converter.ts` converts OpenAPI paths to MCP tools
39-
- Naming with API prefix: `accounting_get_deals`, `hr_get_employees`, `invoice_get_delivery_slips`, `pm_get_projects`, `sm_get_businesses`
40-
- Each tool automatically uses the correct base URL for its API
29+
- **Tool Generation**: `generateClientModeTool()` in `src/openapi/client-mode.ts` creates method-specific tools
30+
- Tools: `freee_api_get`, `freee_api_post`, `freee_api_put`, `freee_api_delete`, `freee_api_patch`, `freee_api_list_paths`
31+
- Automatically detects API type from path and uses correct base URL
32+
- Validates paths against all OpenAPI schemas before execution
33+
- Supports all 5 freee APIs seamlessly
4134
- **Requests**: `makeApiRequest()` in `src/api/client.ts` handles API calls with auto-auth and company_id injection
4235

4336
### Configuration
4437

4538
#### Recommended Setup (Config File)
4639

4740
Run `freee-mcp configure` to set up configuration interactively:
41+
4842
- Creates `~/.config/freee-mcp/config.json` with OAuth credentials and company settings
4943
- No environment variables needed
5044
- More secure (file permissions 0600)
@@ -60,8 +54,8 @@ Run `freee-mcp configure` to set up configuration interactively:
6054

6155
### CLI Subcommands
6256

63-
- `freee-mcp client` - Start in client mode (HTTP method sub-commands)
64-
- `freee-mcp api` - Start in API mode (individual tools per endpoint) [default]
57+
- `freee-mcp` - Start MCP server
58+
- `freee-mcp configure` - Interactive configuration setup
6559

6660
### MCP Configuration
6761

@@ -82,68 +76,24 @@ After running `freee-mcp configure`:
8276

8377
Configuration is automatically loaded from `~/.config/freee-mcp/config.json`.
8478

85-
#### Using Environment Variables (Deprecated)
86-
87-
⚠️ **Deprecated: Will be removed in future versions**
88-
89-
**Client Mode (recommended):**
90-
```json
91-
{
92-
"mcpServers": {
93-
"freee": {
94-
"command": "npx",
95-
"args": ["@him0/freee-mcp", "client"],
96-
"env": {
97-
"FREEE_CLIENT_ID": "your_client_id",
98-
"FREEE_CLIENT_SECRET": "your_client_secret",
99-
"FREEE_CALLBACK_PORT": "54321"
100-
}
101-
}
102-
}
103-
}
104-
```
105-
106-
**API Mode (individual tools):**
107-
```json
108-
{
109-
"mcpServers": {
110-
"freee": {
111-
"command": "npx",
112-
"args": ["@him0/freee-mcp", "api"],
113-
"env": {
114-
"FREEE_CLIENT_ID": "your_client_id",
115-
"FREEE_CLIENT_SECRET": "your_client_secret",
116-
"FREEE_COMPANY_ID": "your_company_id",
117-
"FREEE_CALLBACK_PORT": "54321"
118-
}
119-
}
120-
}
121-
}
122-
```
123-
124-
**Client Mode vs Individual Mode**:
125-
- Use `freee-mcp client` for HTTP method sub-command tools (recommended for large APIs)
126-
- 6 tools total: freee_api_{get,post,put,delete,patch} + freee_api_list_paths
127-
- Significantly reduces context window usage
128-
- Use `freee-mcp api` for individual tools per endpoint (more granular but uses more context)
129-
- Hundreds of tools (one per API endpoint)
130-
131-
Development mode: Use `"command": "pnpm", "args": ["tsx", "src/index.ts", "client"]` with `"cwd": "/path/to/freee-mcp"`
79+
Development mode: Use `"command": "pnpm", "args": ["tsx", "src/index.ts"]` with `"cwd": "/path/to/freee-mcp"`
13280

13381
## PR Creation Pre-flight Checklist
13482

13583
**Always run before creating a PR:**
13684

13785
```bash
138-
pnpm type-check && pnpm lint && pnpm test:run && pnpm build
86+
pnpm typecheck && pnpm lint && pnpm test:run && pnpm build
13987
```
14088

14189
**Changeset requirement:**
90+
14291
- Run `pnpm changeset` to create a changeset file for any user-facing changes
14392
- Select the appropriate bump type: `patch` (bug fixes), `minor` (new features), `major` (breaking changes)
14493
- Write a concise description of what changed for the CHANGELOG
14594

14695
**Common issues:**
96+
14797
- Mock function return types (ensure `id` fields are strings)
14898
- Missing return type annotations on exported functions
14999
- Undefined environment variables in tests

README.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ npx @him0/freee-mcp configure
4949
"mcpServers": {
5050
"freee": {
5151
"command": "npx",
52-
"args": ["@him0/freee-mcp", "client"]
52+
"args": ["@him0/freee-mcp"]
5353
}
5454
}
5555
}
5656
```
5757

58+
> **⚠️ 環境変数での設定について**
59+
> 環境変数(`FREEE_CLIENT_ID``FREEE_CLIENT_SECRET` など)を使った設定は非推奨です。
60+
> 代わりに `npx @him0/freee-mcp configure` を実行して設定ファイルに移行してください。
61+
> 環境変数設定は将来のバージョンで削除される予定です。
62+
5863
## Claude Plugin として使う
5964

6065
Claude Code でプラグインとしてインストールすると、API リファレンス付きのスキルが利用できます:
@@ -88,25 +93,6 @@ Claude との会話中に API の使い方を質問すると、これらのリ
8893
例: 「先月の○○社への請求書を参考に、今月分を作成して」
8994
```
9095

91-
## 起動モード
92-
93-
freee-mcp は2つのモードで起動できます:
94-
95-
```bash
96-
# クライアントモード(推奨):HTTPメソッド別の6ツール
97-
npx @him0/freee-mcp client
98-
99-
# APIモード:エンドポイントごとの個別ツール(数百個)
100-
npx @him0/freee-mcp api
101-
# または
102-
npx @him0/freee-mcp
103-
```
104-
105-
| モード | ツール数 | 特徴 | 推奨 |
106-
| ------ | -------- | ---- | ---- |
107-
| client | 6個 | コンテキスト使用量が少ない、任意のパスを指定可能 ||
108-
| api | 数百個 | エンドポイントごとに専用ツール、コンテキスト消費大 ||
109-
11096
## 利用可能なツール
11197

11298
### 管理ツール
@@ -120,7 +106,7 @@ npx @him0/freee-mcp
120106
| `freee_help` | 使い方ガイド |
121107
| `freee_status` | 現在の状態と推奨アクション |
122108

123-
### API ツール(クライアントモード)
109+
### API ツール
124110

125111
HTTPメソッドごとのシンプルなツール構成:
126112

@@ -144,7 +130,7 @@ pnpm install
144130

145131
pnpm dev # 開発サーバー(ウォッチモード)
146132
pnpm build # ビルド
147-
pnpm type-check # 型チェック
133+
pnpm typecheck # 型チェック
148134
pnpm lint # リント
149135
pnpm test:run # テスト
150136

@@ -156,6 +142,10 @@ pnpm generate:references
156142

157143
TypeScript / Model Context Protocol SDK / OAuth 2.0 + PKCE / Zod / esbuild
158144

145+
### アーキテクチャ詳細
146+
147+
プロジェクトのアーキテクチャ、内部構造、開発ガイドラインについては [CLAUDE.md](./CLAUDE.md) を参照してください。
148+
159149
## ライセンス
160150

161151
ISC

src/config.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { loadFullConfig } from './config/companies.js';
22
import { DEFAULT_CALLBACK_PORT, AUTH_TIMEOUT_MS } from './constants.js';
33

4-
// Mode can be set programmatically via setMode()
5-
let clientMode = false;
6-
74
export interface Config {
85
freee: {
96
clientId: string;
@@ -135,16 +132,3 @@ export const config = new Proxy({} as Config, {
135132
},
136133
});
137134

138-
/**
139-
* Sets the API mode (client or individual tools)
140-
*/
141-
export function setMode(useClient: boolean): void {
142-
clientMode = useClient;
143-
}
144-
145-
/**
146-
* Get current mode (client or individual tools)
147-
*/
148-
export function getMode(): boolean {
149-
return clientMode;
150-
}

0 commit comments

Comments
 (0)