Skip to content

oracle-japan/ochacafe-master-of-next-level-llm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oracle Cloud Hangout Cafe Season 10 #2 「LLM 拡張解体新書」の MCP デモ

ディレクトリ構成

.
├── .gitignore
├── .python-version
├── .venv
├── README.md
├── inspector.sh # インスペクタ起動用スクリプト
├── main.py # メインスクリプト
├── pyproject.toml
└── uv.lock

前提条件と環境

  • python 3.10+
  • node.js 22.7.5+
  • uv
  • OCI 環境(有償無償不問、大阪リージョン必須)

事前準備

Computeインスタンスの作成

こちらの手順を参考にComputeインスタンスを作成します。

OKE のプロビジョニング

こちらの手順を参考にComputeインスタンスを作成します。

API キーの設定

コンソール右上の人型マークをクリックし、ユーザ名をクリックします。

画面をスクロールし、APIキーをクリックします。

APIキーの追加をクリックします。

秘密キーのダウンロードをクリックし、追加をクリックします。

上記で作成したComputeインスタンス上の~/.oci/configに貼り付けます。

OCI Generative AI Agents のエンドポイント作成

OCIコンソールにログインし、アナリティクスとAIから生成AIエージェントをクリックします。

以下のステップにそって、エージェントとエンドポイントを作成します。

ステータスがアクティブになったら、エンドポイントをクリックします。

エンドポイントの OCID を取得し、エディタなどにに控えておきます。

エージェントのエンドポイントの差し替え

レポジトリ直下にあるmain.pyの以下のポイントを編集します。 <エンドポイントのOCID>を上記で控えたOCIDに差し替えます。

        agent = Agent(
            client=client,
            agent_endpoint_id="<エンドポイントのOCID>",
            instructions="You perform a professional kubernetes engineer and OCI expert. ",
            tools=[await k8s_mcp_client.as_toolkit(), await ocidoc_mcp_client.as_toolkit()],
        )

実行手順

MCP inspector の実行

以下のコマンドを実行します

./inspector.sh

http://localhost:6274にアクセスします。

main.py の実行

以下のコマンドを実行します。

uv lock --upgrade
uv run main.py

以下のように出力されたら、OCI Generative AI Agents に Tools が登録され始めます。

[07/10/25 15:41:04]  INFO     MCP client created with pid: 2824257                                                                                                        
[07/10/25 15:41:06]  INFO     MCP client created with pid: 2824350                                                                                                        
⠙ pydantic==2.11.7                                                                                                                                                        
[07/10/25 15:41:07] INFO     Processing request of type ListToolsRequest                                                                                     server.py:619
[07/10/25 15:41:07]  INFO     Checking integrity of agent details...                                                                                                      
                     INFO     Checking synchronization of local and remote agent settings...                                                                              
                     INFO     Agent settings are not synchronized. Updating remote agent settings                                                                         
[07/10/25 15:41:13]  INFO     Waiting for agent ocid1.genaiagent.oc1.ap-osaka-1.amaaaaaassl65iqaju575y3sjqmmik4mirq733x32j5qptqvzqsumsduuqqq to be active...              
[07/10/25 15:41:18]  INFO     Waiting for agent ocid1.genaiagent.oc1.ap-osaka-1.amaaaaaassl65iqaju575y3sjqmmik4mirq733x32j5qptqvzqsumsduuqqq to be active...              
[07/10/25 15:41:23]  INFO     Waiting for agent ocid1.genaiagent.oc1.ap-osaka-1.amaaaaaassl65iqaju575y3sjqmmik4mirq733x32j5qptqvzqsumsduuqqq to be active...              
                     INFO     Checking synchronization of local and remote function tools...                                                                              
╭──────────────────────────────────────────────────────────────── Local and remote function tools found ─────────────────────────────────────────────────────────────────╮
│ Local function tools (20):                                                                                                                                             │
│ ['configuration_view', 'events_list', 'helm_install', 'helm_list', 'helm_uninstall', 'namespaces_list', 'pods_delete', 'pods_exec', 'pods_get', 'pods_list',           │
│ 'pods_list_in_namespace', 'pods_log', 'pods_run', 'pods_top', 'read_documentation', 'resources_create_or_update', 'resources_delete', 'resources_get',                 │
│ 'resources_list', 'search_documentation']                                                                                                                              │
│                                                                                                                                                                        │
│ Remote function tools (0):                                                                                                                                             │
│ []                                                                                                                                                                     │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                     INFO     Adding local tool configuration_view to remote...   

About

OCHaCafe Season10 #2「LLM拡張解体新書」で利用したデモコード

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published