This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bun run build- Build the project (uses Bun.build)bun run typecheck- TypeScript type checkingbun run lint- Run Biome linterbun run format- Run Biome formatterbun run check- Run Biome lint + format (recommended before PR)bun run test:run- Run tests (vitest)bun run dev- Start development serverbun run inspector- MCP inspector for debugging toolsbun run changeset- Create a new changeset for version bumpsbun run version- Apply changesets to update versions and CHANGELOGbun run release- Build and publish to npm
MCP server that exposes freee API endpoints as MCP tools:
- Schema: Multiple OpenAPI schemas in
openapi/directoryaccounting-api-schema.json- 会計API (https://api.freee.co.jp)hr-api-schema.json- 人事労務API (https://api.freee.co.jp/hr)invoice-api-schema.json- 請求書API (https://api.freee.co.jp/iv)pm-api-schema.json- 工数管理API (https://api.freee.co.jp/pm)sm-api-schema.json- 販売API (https://api.freee.co.jp/sm)sign-api-schema.json- サイン(電子契約)API (https://ninja-sign.com)
- Schema Loader:
src/openapi/schema-loader.tsloads and manages all API schemas - Tool Generation:
generateClientModeTool()insrc/openapi/client-mode.tscreates method-specific tools- Tools:
freee_api_get,freee_api_post,freee_api_put,freee_api_delete,freee_api_patch,freee_api_list_paths - Automatically detects API type from path and uses correct base URL
- Validates paths against all OpenAPI schemas before execution
- Supports all 5 freee APIs seamlessly
- Tools:
- Requests:
makeApiRequest()insrc/api/client.tshandles API calls with auto-auth and company_id injection
Run freee-mcp configure to set up configuration interactively:
- Creates
~/.config/freee-mcp/config.jsonwith OAuth credentials and company settings - More secure (file permissions 0600)
freee-mcp- Start MCP serverfreee-mcp configure- Interactive configuration setupfreee-sign-mcp- Start Sign MCP serverfreee-sign-mcp configure- Sign interactive configuration setup
After running freee-mcp configure:
{
"mcpServers": {
"freee": {
"command": "npx",
"args": ["freee-mcp"]
}
}
}Configuration is automatically loaded from ~/.config/freee-mcp/config.json.
Development mode: Use "command": "bun", "args": ["run", "src/index.ts"] with "cwd": "/path/to/freee-mcp"
Sign development mode: Use "command": "bun", "args": ["run", "src/sign/index.ts"] with "cwd": "/path/to/freee-mcp"
環境変数 FREEE_API_BASE_URL_{SERVICE} でAPIの向き先を変更できる(src/openapi/schema-loader.ts の resolveBaseUrl で処理)。
FREEE_API_BASE_URL- freee public APIのベースURLFREEE_API_BASE_URL_ACCOUNTING- 会計APIFREEE_API_BASE_URL_HR- 人事労務APIFREEE_API_BASE_URL_INVOICE- 請求書APIFREEE_API_BASE_URL_PM- 工数管理APIFREEE_API_BASE_URL_SM- 販売APIFREEE_SIGN_API_URL- サインAPI(src/sign/config.tsで処理)
Remote モードは「1 HTTP リクエスト = 1 ログ行 = 1 trace」パターン。ペイロード形状は CanonicalLogPayload (src/server/request-context.ts)、emit は src/telemetry/middleware.ts の res.on('finish')。
読み落としやすい注意点:
- synthetic error (validation 失敗、routing 404 等) は
makeErrorChain(name, message)経由で登録すること。素の[{ name, message }]リテラルはscrubErrorMessage()を通らず privacy 漏洩の原因になる http.statusは MCP クライアントへの最終応答、api_calls[].status_codeは freee API からの応答。freee API 500 でも MCP 応答は 200 で wrap する場合があり、両方を見る必要がある
Datadog 検索例:
@http.status:500— MCP サーバー自体の 5xx@api_calls.error_type:timeout— 外部 API タイムアウト@http.status:200 @errors:*— 見かけ上は成功だが内部的に失敗@request_id:<uuid>— 特定リクエストの全情報@user_agent:ClaudeDesktop*— MCP クライアント種別でフィルタ
Always run before creating a PR:
bun run typecheck && bun run lint && bun run test:run && bun run buildChangeset requirement (必須):
- コミット時に changeset ファイルを必ず作成すること(忘れやすいので注意)
bun run changesetが対話モードで使えない場合は.changeset/<短い説明>.mdを直接作成する- フォーマット: frontmatter に
"freee-mcp": patch|minor|major、本文に変更内容の説明(日本語) - bump type:
patch(バグ修正)、minor(新機能)、major(破壊的変更)
Changeset の書き方:
- 1 行サマリ+必要に応じて短い箇条書き(2〜5 項目)に留める。実装詳細・内部モジュール名・facet 名等は PR 説明に書き、CHANGELOG には残さない
- BREAKING や運用影響(ダッシュボード移行など)の警告だけは要約として明示する
- サブセクション(
## 〇〇)を切る粒度の長文は避ける
Contributor の追加:
- Issue を起票してくれた人を README.md の Contributors セクション(
<!-- CONTRIBUTORS-START -->~<!-- CONTRIBUTORS-END -->の間)に追加する - 既存のフォーマットに合わせて
<a href="https://github.com/{username}"><img src="https://github.com/{username}.png" width="40" height="40" alt="@{username}"></a>を末尾に追記する
Common issues:
- Mock function return types (ensure
idfields are strings) - Missing return type annotations on exported functions
- Undefined environment variables in tests
skills/freee-api-skill/内のVERSION.mdは npm publish 時に自動生成されるため、開発環境(ローカル)には存在しない- 開発環境では
freee_server_infoのバージョンがdevと返る(正常動作)。実際のバージョンはpackage.jsonのversionを参照する - Skill の更新(レシピ・リファレンスの追加・修正など)は changeset で
patchバージョンとする
- レシピ(
skills/*/recipes/)は操作の流れと注意点に集中し、APIの仕様詳細(パス一覧・パラメータ・レスポンス・制約等)はリファレンス(references/)へのパス参照に留める - レシピにリファレンスと同じ情報を重複して書かない
- Do not use markdown bold syntax (
**) in any files - PR の説明・コミットメッセージ・CHANGELOG・ドキュメント等の公開される文章には、freee organization 以外のリポジトリ(フォーク含む)への参照や、Jira などの社内ツールの URL を書かない