0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

社内のDXプロジェクトで使えそうな「AI Agent with MCPサーバ」作ってみた

0
Last updated at Posted at 2026-03-01

作ったもの

GitHubはこちら

👉 https://github.com/barcarunrun/AI_Agent_Invoice

「○○会社への2026年1月の請求金額を教えて」

と聞くと請求額を返します。

さらに、

「請求書作って」

と言うと、請求書を自動生成します。

つまり、

  • データ取得
  • 状態理解
  • 次アクション実行

までを、自然言語だけで完結します。

※動画はgithub上にあります。

仕組みはシンプル

MCPサーバを立てて繋いでるだけです。

実際、LLMに対してやっていることはこれだけです。

const response = await openAiClient.responses.create({
  model: openAiModel,
  input,
  tools: [
    {
      type: "mcp",
      server_label: "minimal-mcp-on-aws",
      server_url: mcpServerUrl,
      require_approval: "never",
    },
  ],
});

何が起きているのか?

このコードは、

  • OpenAIのResponses API
  • MCPサーバ
  • ツール自動呼び出し

を接続しています。

つまり:

ユーザーの自然言語
        ↓
OpenAIが意図理解
        ↓
必要なツールをMCP経由で自動実行
        ↓
結果をまとめて回答

MCPサーバ側には、

・get_monthly_invoice
・issue_monthly_invoice_pdf

などのツールが定義されています。

OpenAIはそれを見て、

「この質問にはこのツールが必要」

と判断して自動で呼び出します。

こちらは if文もswitchも書いていません。


アーキテクチャ(イメージ)

[User]
   ↓
[OpenAI Responses API]
   ↓
[MCP Server]
   ↓
[DB / Business Logic]

社内システムの既存APIを
そのままMCPツールとして公開するだけでできます。

最後に

DXの本丸は、「AI Agent with MCPサーバ」なんではないかと思っており、
こういった実装がガンガン増えると嬉しいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?