Skip to content
Open
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
210 changes: 210 additions & 0 deletions tutorial_ja/.ipynb_checkpoints/start_here_ja-checkpoint.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

625 changes: 625 additions & 0 deletions tutorial_ja/jupyter_notebook/01_inference_endpoint_ja.ipynb

Large diffs are not rendered by default.

498 changes: 498 additions & 0 deletions tutorial_ja/jupyter_notebook/02_introduction_mcp_ja.ipynb

Large diffs are not rendered by default.

587 changes: 587 additions & 0 deletions tutorial_ja/jupyter_notebook/03_low_level_mcp_ja.ipynb

Large diffs are not rendered by default.

1,303 changes: 1,303 additions & 0 deletions tutorial_ja/jupyter_notebook/04_langraph_agent_ja.ipynb

Large diffs are not rendered by default.

1,413 changes: 1,413 additions & 0 deletions tutorial_ja/jupyter_notebook/05_nemo_agent_toolkit_ja.ipynb

Large diffs are not rendered by default.

652 changes: 652 additions & 0 deletions tutorial_ja/jupyter_notebook/06_challenge_ja.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "f879e9da-a45d-4b9b-95d7-12125f92d248",
"metadata": {},
"source": [
"<p> <center> <a href=\"../../start_here_ja.ipynb\">Home Page</a> </center> </p>\n",
"\n",
"<div>\n",
" <span style=\"float: left; width: 33%; text-align: left;\"><a href=\"../06_challenge_ja.ipynb\">Previous Notebook</a></span>\n",
" <span style=\"float: left; width: 34%; text-align: center;\">\n",
" <a href=\"../01_inference_endpoint_ja.ipynb\">1</a>\n",
" <a href=\"../02_introduction_mcp_ja.ipynb\">2</a>\n",
" <a href=\"../03_low_level_mcp_ja.ipynb\">3</a>\n",
" <a href=\"../04_langraph_agent_ja.ipynb\">4</a>\n",
" <a href=\"../05_nemo_agent_toolkit_ja.ipynb\">5</a>\n",
" <a href=\"../06_challenge_ja.ipynb\">6</a>\n",
" <a >7</a>\n",
" </span>\n",
" <span style=\"float: left; width: 33%; text-align: right;\"></span>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"id": "ff4f795b-7ddd-49da-98b7-e5e54d6e46d6",
"metadata": {},
"source": [
"# ボーナスチャレンジ — OpenClaw 連携"
]
},
{
"cell_type": "markdown",
"id": "94a09d77-47fa-485c-a9cf-e71d167c1fa7",
"metadata": {},
"source": [
"このボーナスチャレンジでは、メインのワークショップチャレンジを発展させ、完成させたソリューション(MCP invoice server と NemoClaw Agent Toolkit workflow)を **OpenClaw** に統合します。OpenClaw はセルフホスト型の AI アシスタントで、プラットフォームを横断してあなたの代わりにアクションを実行できます。\n",
"\n",
"ご自身の環境に合うセットアップ経路を選んでください:"
]
},
{
"cell_type": "markdown",
"id": "4d4c951d-62f6-4b5b-8a5b-235d01446fe4",
"metadata": {},
"source": [
"## [07a — Docker セットアップ](07_bonus_challenge_docker_ja.ipynb)\n",
"\n",
"OpenClaw を Docker コンテナ内で実行し、完全に隔離された環境を用意します。チャレンジリポジトリはコンテナにマウントされるので、完成させたソリューションファイルが agent から利用可能になります。ホストシステムへの変更を避けたい場合や、再現可能で使い捨てのセットアップが必要な場合に推奨されます。\n",
"\n",
"**主なステップ:** OpenClaw リポジトリを clone → チャレンジリポジトリを mount → Docker image を pull → OpenClaw CLI とファイルシステムの直接編集で music-store agent を設定 → コンテナ内で MCP と NAT サーバーを起動 → TUI 経由で agent にクエリ → セッション trace を確認。"
]
},
{
"cell_type": "markdown",
"id": "d9abe5d2-f665-4ca4-84a0-d08eb85e4d6f",
"metadata": {},
"source": [
"## [07b — ホストインストール](07_bonus_challenge_host_ja.ipynb)\n",
"\n",
"OpenClaw をホストマシン上に直接実行します。この経路ではシェルスクリプトを使って OpenClaw をネイティブにインストールし、systemd サービスとして設定し、music-store agent skill を NAT workflow endpoint に接続します。OS への完全なアクセス権がある Linux システムに最適です。\n",
"\n",
"**主なステップ:** OpenClaw CLI をインストール → music-store agent を設定 → ホスト上で MCP と NAT サーバーを起動 → TUI またはダッシュボード経由で agent にクエリ → セッション trace を確認。"
]
},
{
"cell_type": "markdown",
"id": "c76f09cb-3c4e-4974-b051-951e7d4f285f",
"metadata": {},
"source": [
"Copyright &copy; 2026 OpenACC-Standard.org. 本資料は OpenACC-Standard.org が NVIDIA Corporation との協力のもと、Creative Commons Attribution 4.0 International (CC BY 4.0) ライセンスのもとで公開しています。本資料には他の団体が開発したハードウェアおよびソフトウェアへの参照が含まれており、該当するすべてのライセンスおよび著作権が適用されます。"
]
},
{
"cell_type": "markdown",
"id": "53946d83-bf44-4a27-9c98-b38cc291361f",
"metadata": {},
"source": [
"<p> <center> <a href=\"../../start_here_ja.ipynb\">Home Page</a> </center> </p>\n",
"\n",
"<div>\n",
" <span style=\"float: left; width: 33%; text-align: left;\"><a href=\"../06_challenge_ja.ipynb\">Previous Notebook</a></span>\n",
" <span style=\"float: left; width: 34%; text-align: center;\">\n",
" <a href=\"../01_inference_endpoint_ja.ipynb\">1</a>\n",
" <a href=\"../02_introduction_mcp_ja.ipynb\">2</a>\n",
" <a href=\"../03_low_level_mcp_ja.ipynb\">3</a>\n",
" <a href=\"../04_langraph_agent_ja.ipynb\">4</a>\n",
" <a href=\"../05_nemo_agent_toolkit_ja.ipynb\">5</a>\n",
" <a href=\"../06_challenge_ja.ipynb\">6</a>\n",
" <a >7</a>\n",
" </span>\n",
" <span style=\"float: left; width: 33%; text-align: right;\"></span>\n",
"</div>"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added tutorial_ja/jupyter_notebook/data/movie.sqlite
Binary file not shown.
Binary file added tutorial_ja/jupyter_notebook/images/aiq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial_ja/jupyter_notebook/images/aiq_arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorial_ja/jupyter_notebook/images/claude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 155 additions & 0 deletions tutorial_ja/jupyter_notebook/mcp_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
"""
MCP Client that connects to and invokes tools from MCP servers.

Supports:
- Stdio transport (for local servers)
- HTTP transport (for remote/HTTP servers)

Usage:
python mcp_client.py # Default: mcp_server.py (stdio)
python mcp_client.py mcp_server.py # High-level server (stdio)
python mcp_client.py mcp_server_low_level.py # Low-level server (stdio)
python mcp_client.py --http # HTTP mode (localhost:${MCP_PORT:-8000})
python mcp_client.py --http http://custom:8080/mcp # Custom HTTP URL
"""

import asyncio
import argparse
import os
from typing import Optional
from contextlib import AsyncExitStack
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from mcp.client.streamable_http import streamablehttp_client

DEFAULT_MCP_PORT = os.environ.get("MCP_PORT") or "8000"
DEFAULT_HTTP_URL = f"http://localhost:{DEFAULT_MCP_PORT}/mcp"


class MCPClient:
"""A client for connecting to MCP servers via Stdio or HTTP transport."""

# ===========================================
# Step 1: Initialize __init__()
# Set up session placeholder and AsyncExitStack for resource management
# ===========================================
def __init__(self):
self.session: Optional[ClientSession] = None
self.exit_stack = AsyncExitStack()

# ===========================================
# Step 2: Define connect_to_server()
# Launch and connect to local server via Stdio transport
# ===========================================
async def connect_to_server(self, server_script_path: str):
print(f"→ Connecting to server: {server_script_path}")
server_params = StdioServerParameters(
command="python",
args=[server_script_path]
)
stdio_transport = await self.exit_stack.enter_async_context(
stdio_client(server_params)
)
self.stdio, self.write = stdio_transport
self.session = await self.exit_stack.enter_async_context(
ClientSession(self.stdio, self.write)
)
await self.session.initialize()

# ===========================================
# Step 3: Define connect_to_server_http()
# Connect to remote server via HTTP transport
# ===========================================
async def connect_to_server_http(self, url: str):
print(f"→ Connecting to HTTP server: {url}")
streamablehttp_transport = await self.exit_stack.enter_async_context(
streamablehttp_client(url)
)
self.read, self.write, _ = streamablehttp_transport
self.session = await self.exit_stack.enter_async_context(
ClientSession(self.read, self.write)
)
await self.session.initialize()

# ===========================================
# Step 4: Define list_tools()
# Discover available tools from the connected server
# ===========================================
async def list_tools(self):
res_tools = await self.session.list_tools()
return res_tools.tools

# ===========================================
# Step 5: Define call_tool()
# Execute a specific tool with arguments
# ===========================================
async def call_tool(self, tool_name: str, arguments: dict):
result = await self.session.call_tool(tool_name, arguments)
return result.content[0].text

# ===========================================
# Step 6: Define cleanup()
# Release all resources by closing the AsyncExitStack
# ===========================================
async def cleanup(self):
await self.exit_stack.aclose()


async def test_tools(client: MCPClient):
"""Test the available tools on the connected server."""
tools = await client.list_tools()
print(f"\n✓ Connected to server with tools: {[tool.name for tool in tools]}")

print("\n→ Calling add(2, 3)")
result = await client.call_tool('add', {'a': 2, 'b': 3})
print(f" Result: {result}")

print("\n→ Calling subtract(7, 4)")
result = await client.call_tool('subtract', {'a': 7, 'b': 4})
print(f" Result: {result}")


async def main_stdio(server_path: str):
"""Run client with Stdio transport."""
client = MCPClient()
try:
await client.connect_to_server(server_path)
await test_tools(client)
finally:
await client.cleanup()


async def main_http(url: str):
"""Run client with HTTP transport."""
client = MCPClient()
try:
await client.connect_to_server_http(url)
await test_tools(client)
finally:
await client.cleanup()


if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="MCP Client - Connect to MCP servers and invoke tools"
)
parser.add_argument(
'server',
nargs='?',
default='mcp_server.py',
help='Path to server script (default: mcp_server.py)'
)
parser.add_argument(
'--http',
nargs='?',
const=DEFAULT_HTTP_URL,
help=f'Use HTTP transport (default URL: {DEFAULT_HTTP_URL})'
)

args = parser.parse_args()

if args.http:
url = args.http
asyncio.run(main_http(url))
else:
asyncio.run(main_stdio(args.server))
54 changes: 54 additions & 0 deletions tutorial_ja/jupyter_notebook/mcp_server.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
INFO: Started server process [29737]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:63989 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:63989 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:63990 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64006 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64006 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64007 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64007 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64007 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64017 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64017 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64018 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64018 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64018 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64029 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64029 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64030 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64038 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64038 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64039 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64064 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64064 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64065 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64065 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64065 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64080 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64080 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64081 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64095 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64095 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64096 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64101 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64101 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64102 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64102 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64102 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64174 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64174 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64175 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64246 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64246 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64247 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64306 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64306 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO: 127.0.0.1:64307 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64307 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: 127.0.0.1:64307 - "POST /mcp/ HTTP/1.1" 200 OK
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [29737]
41 changes: 41 additions & 0 deletions tutorial_ja/jupyter_notebook/mcp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
MCP Server using FastMCP (High-Level SDK)
This server exposes simple math tools that can be invoked by MCP clients.
"""

from mcp.server.fastmcp import FastMCP

# Create an MCP server instance with a descriptive name
mcp = FastMCP("simple-math")

# Define the 'add' tool using the @mcp.tool() decorator
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers together.

Args:
a: First integer
b: Second integer

Returns:
Sum of a and b
"""
return a + b

# Define the 'subtract' tool
@mcp.tool()
def subtract(a: int, b: int) -> int:
"""Subtract second number from first.

Args:
a: First integer
b: Second integer

Returns:
Difference (a - b)
"""
return a - b

if __name__ == "__main__":
# Run the MCP server with SSE transport over HTTP
mcp.run(transport="stdio")
Loading