From 287b9c45d40f442d6f5bae5bc73faa649b3294ec Mon Sep 17 00:00:00 2001 From: emahiro Date: Tue, 8 Apr 2025 23:51:41 +0900 Subject: [PATCH 1/3] fix: mcp server name --- my-fastmcp-app/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/my-fastmcp-app/src/index.ts b/my-fastmcp-app/src/index.ts index 13e1dbb..b6bc355 100644 --- a/my-fastmcp-app/src/index.ts +++ b/my-fastmcp-app/src/index.ts @@ -2,7 +2,7 @@ import { FastMCP } from "fastmcp"; import { z } from "zod"; const server = new FastMCP({ - name: "my-fastmcp-app", + name: "my-fastmcp-server", version: "1.0.0", }); From c4d5808d5025aab17d1aca3cdbf5408f1441c75b Mon Sep 17 00:00:00 2001 From: emahiro Date: Tue, 8 Apr 2025 23:56:02 +0900 Subject: [PATCH 2/3] fix: biome setting --- biome.json | 11 +++- my-fastmcp-app/src/index.ts | 14 ++--- my-mastra-app/src/mastra/agents/index.ts | 18 +++--- my-mastra-app/src/mastra/index.ts | 10 +-- my-mastra-app/src/mastra/tools/index.ts | 80 ++++++++++++------------ 5 files changed, 70 insertions(+), 63 deletions(-) diff --git a/biome.json b/biome.json index 2eb0751..3915621 100644 --- a/biome.json +++ b/biome.json @@ -11,7 +11,8 @@ }, "formatter": { "enabled": true, - "indentStyle": "tab" + "indentStyle": "tab", + "indentWidth": 2 }, "organizeImports": { "enabled": true @@ -24,7 +25,13 @@ }, "javascript": { "formatter": { - "quoteStyle": "double" + "quoteStyle": "single" + } + }, + "json": { + "formatter": { + "indentStyle": "tab", + "indentWidth": 2 } } } diff --git a/my-fastmcp-app/src/index.ts b/my-fastmcp-app/src/index.ts index b6bc355..cce60a7 100644 --- a/my-fastmcp-app/src/index.ts +++ b/my-fastmcp-app/src/index.ts @@ -1,14 +1,14 @@ -import { FastMCP } from "fastmcp"; -import { z } from "zod"; +import { FastMCP } from 'fastmcp'; +import { z } from 'zod'; const server = new FastMCP({ - name: "my-fastmcp-server", - version: "1.0.0", + name: 'my-fastmcp-server', + version: '1.0.0', }); server.addTool({ - name: "hello", - description: "Say hello", + name: 'hello', + description: 'Say hello', parameters: z.object({ name: z.string(), }), @@ -18,5 +18,5 @@ server.addTool({ }); server.start({ - transportType: "stdio", + transportType: 'stdio', }); diff --git a/my-mastra-app/src/mastra/agents/index.ts b/my-mastra-app/src/mastra/agents/index.ts index 679b0c1..e773f8a 100644 --- a/my-mastra-app/src/mastra/agents/index.ts +++ b/my-mastra-app/src/mastra/agents/index.ts @@ -1,9 +1,9 @@ -import { google } from "@ai-sdk/google"; -import { Agent } from "@mastra/core/agent"; -import { hogeTools, mcpConfig, weatherTool } from "../tools"; +import { google } from '@ai-sdk/google'; +import { Agent } from '@mastra/core/agent'; +import { hogeTools, mcpConfig, weatherTool } from '../tools'; export const weatherAgent = new Agent({ - name: "お天気アシスタント", + name: 'お天気アシスタント', instructions: ` You are a helpful weather assistant that provides accurate weather information. @@ -19,27 +19,27 @@ export const weatherAgent = new Agent({ Use the weatherTool to fetch current weather data. - Ensure to handle errors gracefully and provide fallback responses if necessary. `, - model: google("gemini-1.5-pro-latest"), + model: google('gemini-1.5-pro-latest'), tools: { weatherTool }, }); export const HogeAgent = new Agent({ - name: "hoge Agent", + name: 'hoge Agent', instructions: ` - Always reply "hello world"`, - model: google("gemini-1.5-pro-latest"), + model: google('gemini-1.5-pro-latest'), tools: { hogeTools }, }); // MCP Client Example export const sampleMCPAgent = new Agent({ - name: "sample MCP Agent", + name: 'sample MCP Agent', instructions: ` - You are able to fetch data from URLs on demand and discuss the response data with the user. - If the location name isn’t in English, please translate it // 質問者の言語に合わせて回答する言語を選択すること(ex 日本語で聞かれたら日本語で答える。) - Always respond in the language of the question. `, - model: google("gemini-1.5-pro-latest"), + model: google('gemini-1.5-pro-latest'), tools: await mcpConfig.getTools(), }); diff --git a/my-mastra-app/src/mastra/index.ts b/my-mastra-app/src/mastra/index.ts index 4528807..ecfc075 100644 --- a/my-mastra-app/src/mastra/index.ts +++ b/my-mastra-app/src/mastra/index.ts @@ -1,12 +1,12 @@ -import { createLogger } from "@mastra/core/logger"; -import { Mastra } from "@mastra/core/mastra"; +import { createLogger } from '@mastra/core/logger'; +import { Mastra } from '@mastra/core/mastra'; -import { HogeAgent, sampleMCPAgent, weatherAgent } from "./agents"; +import { HogeAgent, sampleMCPAgent, weatherAgent } from './agents'; export const mastra = new Mastra({ agents: { weatherAgent, HogeAgent, sampleMCPAgent }, logger: createLogger({ - name: "Mastra", - level: "info", + name: 'Mastra', + level: 'info', }), }); diff --git a/my-mastra-app/src/mastra/tools/index.ts b/my-mastra-app/src/mastra/tools/index.ts index 59fa583..5e6da1e 100644 --- a/my-mastra-app/src/mastra/tools/index.ts +++ b/my-mastra-app/src/mastra/tools/index.ts @@ -1,6 +1,6 @@ -import { createTool } from "@mastra/core/tools"; -import { MCPConfiguration } from "@mastra/mcp"; -import { z } from "zod"; +import { createTool } from '@mastra/core/tools'; +import { MCPConfiguration } from '@mastra/mcp'; +import { z } from 'zod'; interface GeocodingResponse { results: { @@ -22,10 +22,10 @@ interface WeatherResponse { } export const weatherTool = createTool({ - id: "get-weather", - description: "Get current weather for a location", + id: 'get-weather', + description: 'Get current weather for a location', inputSchema: z.object({ - location: z.string().describe("City name"), + location: z.string().describe('City name'), }), outputSchema: z.object({ temperature: z.number(), @@ -71,41 +71,41 @@ const getWeather = async (location: string) => { function getWeatherCondition(code: number): string { const conditions: Record = { // 日本語で翻訳を付ける - 0: "Clear sky", // 晴れ - 1: "Mainly clear", // 主に晴れ - 2: "Partly cloudy", - 3: "Overcast", - 45: "Foggy", - 48: "Depositing rime fog", - 51: "Light drizzle", - 53: "Moderate drizzle", - 55: "Dense drizzle", - 56: "Light freezing drizzle", - 57: "Dense freezing drizzle", - 61: "Slight rain", - 63: "Moderate rain", - 65: "Heavy rain", - 66: "Light freezing rain", - 67: "Heavy freezing rain", - 71: "Slight snow fall", - 73: "Moderate snow fall", - 75: "Heavy snow fall", - 77: "Snow grains", - 80: "Slight rain showers", - 81: "Moderate rain showers", - 82: "Violent rain showers", - 85: "Slight snow showers", - 86: "Heavy snow showers", - 95: "Thunderstorm", - 96: "Thunderstorm with slight hail", - 99: "Thunderstorm with heavy hail", + 0: 'Clear sky', // 晴れ + 1: 'Mainly clear', // 主に晴れ + 2: 'Partly cloudy', + 3: 'Overcast', + 45: 'Foggy', + 48: 'Depositing rime fog', + 51: 'Light drizzle', + 53: 'Moderate drizzle', + 55: 'Dense drizzle', + 56: 'Light freezing drizzle', + 57: 'Dense freezing drizzle', + 61: 'Slight rain', + 63: 'Moderate rain', + 65: 'Heavy rain', + 66: 'Light freezing rain', + 67: 'Heavy freezing rain', + 71: 'Slight snow fall', + 73: 'Moderate snow fall', + 75: 'Heavy snow fall', + 77: 'Snow grains', + 80: 'Slight rain showers', + 81: 'Moderate rain showers', + 82: 'Violent rain showers', + 85: 'Slight snow showers', + 86: 'Heavy snow showers', + 95: 'Thunderstorm', + 96: 'Thunderstorm with slight hail', + 99: 'Thunderstorm with heavy hail', }; - return conditions[code] || "Unknown"; + return conditions[code] || 'Unknown'; } export const hogeTools = createTool({ - id: "hoge", - description: "hoge", + id: 'hoge', + description: 'hoge', inputSchema: z.object({ hoge: z.string(), }), @@ -122,11 +122,11 @@ export const hogeTools = createTool({ // MCP Config export const mcpConfig = new MCPConfiguration({ - id: "my-mcp-config", + id: 'my-mcp-config', servers: { timeMCP: { - command: "podman", - args: ["run", "-i", "--rm", "mcp/time"], + command: 'podman', + args: ['run', '-i', '--rm', 'mcp/time'], }, }, }); From 188423ecfd17965f0c331deda212651f7d16808d Mon Sep 17 00:00:00 2001 From: emahiro Date: Tue, 8 Apr 2025 23:57:30 +0900 Subject: [PATCH 3/3] fix: double quote --- biome.json | 2 +- my-fastmcp-app/src/index.ts | 14 ++--- my-mastra-app/src/mastra/agents/index.ts | 18 +++--- my-mastra-app/src/mastra/index.ts | 10 +-- my-mastra-app/src/mastra/tools/index.ts | 80 ++++++++++++------------ 5 files changed, 62 insertions(+), 62 deletions(-) diff --git a/biome.json b/biome.json index 3915621..b405319 100644 --- a/biome.json +++ b/biome.json @@ -25,7 +25,7 @@ }, "javascript": { "formatter": { - "quoteStyle": "single" + "quoteStyle": "double" } }, "json": { diff --git a/my-fastmcp-app/src/index.ts b/my-fastmcp-app/src/index.ts index cce60a7..b6bc355 100644 --- a/my-fastmcp-app/src/index.ts +++ b/my-fastmcp-app/src/index.ts @@ -1,14 +1,14 @@ -import { FastMCP } from 'fastmcp'; -import { z } from 'zod'; +import { FastMCP } from "fastmcp"; +import { z } from "zod"; const server = new FastMCP({ - name: 'my-fastmcp-server', - version: '1.0.0', + name: "my-fastmcp-server", + version: "1.0.0", }); server.addTool({ - name: 'hello', - description: 'Say hello', + name: "hello", + description: "Say hello", parameters: z.object({ name: z.string(), }), @@ -18,5 +18,5 @@ server.addTool({ }); server.start({ - transportType: 'stdio', + transportType: "stdio", }); diff --git a/my-mastra-app/src/mastra/agents/index.ts b/my-mastra-app/src/mastra/agents/index.ts index e773f8a..679b0c1 100644 --- a/my-mastra-app/src/mastra/agents/index.ts +++ b/my-mastra-app/src/mastra/agents/index.ts @@ -1,9 +1,9 @@ -import { google } from '@ai-sdk/google'; -import { Agent } from '@mastra/core/agent'; -import { hogeTools, mcpConfig, weatherTool } from '../tools'; +import { google } from "@ai-sdk/google"; +import { Agent } from "@mastra/core/agent"; +import { hogeTools, mcpConfig, weatherTool } from "../tools"; export const weatherAgent = new Agent({ - name: 'お天気アシスタント', + name: "お天気アシスタント", instructions: ` You are a helpful weather assistant that provides accurate weather information. @@ -19,27 +19,27 @@ export const weatherAgent = new Agent({ Use the weatherTool to fetch current weather data. - Ensure to handle errors gracefully and provide fallback responses if necessary. `, - model: google('gemini-1.5-pro-latest'), + model: google("gemini-1.5-pro-latest"), tools: { weatherTool }, }); export const HogeAgent = new Agent({ - name: 'hoge Agent', + name: "hoge Agent", instructions: ` - Always reply "hello world"`, - model: google('gemini-1.5-pro-latest'), + model: google("gemini-1.5-pro-latest"), tools: { hogeTools }, }); // MCP Client Example export const sampleMCPAgent = new Agent({ - name: 'sample MCP Agent', + name: "sample MCP Agent", instructions: ` - You are able to fetch data from URLs on demand and discuss the response data with the user. - If the location name isn’t in English, please translate it // 質問者の言語に合わせて回答する言語を選択すること(ex 日本語で聞かれたら日本語で答える。) - Always respond in the language of the question. `, - model: google('gemini-1.5-pro-latest'), + model: google("gemini-1.5-pro-latest"), tools: await mcpConfig.getTools(), }); diff --git a/my-mastra-app/src/mastra/index.ts b/my-mastra-app/src/mastra/index.ts index ecfc075..4528807 100644 --- a/my-mastra-app/src/mastra/index.ts +++ b/my-mastra-app/src/mastra/index.ts @@ -1,12 +1,12 @@ -import { createLogger } from '@mastra/core/logger'; -import { Mastra } from '@mastra/core/mastra'; +import { createLogger } from "@mastra/core/logger"; +import { Mastra } from "@mastra/core/mastra"; -import { HogeAgent, sampleMCPAgent, weatherAgent } from './agents'; +import { HogeAgent, sampleMCPAgent, weatherAgent } from "./agents"; export const mastra = new Mastra({ agents: { weatherAgent, HogeAgent, sampleMCPAgent }, logger: createLogger({ - name: 'Mastra', - level: 'info', + name: "Mastra", + level: "info", }), }); diff --git a/my-mastra-app/src/mastra/tools/index.ts b/my-mastra-app/src/mastra/tools/index.ts index 5e6da1e..59fa583 100644 --- a/my-mastra-app/src/mastra/tools/index.ts +++ b/my-mastra-app/src/mastra/tools/index.ts @@ -1,6 +1,6 @@ -import { createTool } from '@mastra/core/tools'; -import { MCPConfiguration } from '@mastra/mcp'; -import { z } from 'zod'; +import { createTool } from "@mastra/core/tools"; +import { MCPConfiguration } from "@mastra/mcp"; +import { z } from "zod"; interface GeocodingResponse { results: { @@ -22,10 +22,10 @@ interface WeatherResponse { } export const weatherTool = createTool({ - id: 'get-weather', - description: 'Get current weather for a location', + id: "get-weather", + description: "Get current weather for a location", inputSchema: z.object({ - location: z.string().describe('City name'), + location: z.string().describe("City name"), }), outputSchema: z.object({ temperature: z.number(), @@ -71,41 +71,41 @@ const getWeather = async (location: string) => { function getWeatherCondition(code: number): string { const conditions: Record = { // 日本語で翻訳を付ける - 0: 'Clear sky', // 晴れ - 1: 'Mainly clear', // 主に晴れ - 2: 'Partly cloudy', - 3: 'Overcast', - 45: 'Foggy', - 48: 'Depositing rime fog', - 51: 'Light drizzle', - 53: 'Moderate drizzle', - 55: 'Dense drizzle', - 56: 'Light freezing drizzle', - 57: 'Dense freezing drizzle', - 61: 'Slight rain', - 63: 'Moderate rain', - 65: 'Heavy rain', - 66: 'Light freezing rain', - 67: 'Heavy freezing rain', - 71: 'Slight snow fall', - 73: 'Moderate snow fall', - 75: 'Heavy snow fall', - 77: 'Snow grains', - 80: 'Slight rain showers', - 81: 'Moderate rain showers', - 82: 'Violent rain showers', - 85: 'Slight snow showers', - 86: 'Heavy snow showers', - 95: 'Thunderstorm', - 96: 'Thunderstorm with slight hail', - 99: 'Thunderstorm with heavy hail', + 0: "Clear sky", // 晴れ + 1: "Mainly clear", // 主に晴れ + 2: "Partly cloudy", + 3: "Overcast", + 45: "Foggy", + 48: "Depositing rime fog", + 51: "Light drizzle", + 53: "Moderate drizzle", + 55: "Dense drizzle", + 56: "Light freezing drizzle", + 57: "Dense freezing drizzle", + 61: "Slight rain", + 63: "Moderate rain", + 65: "Heavy rain", + 66: "Light freezing rain", + 67: "Heavy freezing rain", + 71: "Slight snow fall", + 73: "Moderate snow fall", + 75: "Heavy snow fall", + 77: "Snow grains", + 80: "Slight rain showers", + 81: "Moderate rain showers", + 82: "Violent rain showers", + 85: "Slight snow showers", + 86: "Heavy snow showers", + 95: "Thunderstorm", + 96: "Thunderstorm with slight hail", + 99: "Thunderstorm with heavy hail", }; - return conditions[code] || 'Unknown'; + return conditions[code] || "Unknown"; } export const hogeTools = createTool({ - id: 'hoge', - description: 'hoge', + id: "hoge", + description: "hoge", inputSchema: z.object({ hoge: z.string(), }), @@ -122,11 +122,11 @@ export const hogeTools = createTool({ // MCP Config export const mcpConfig = new MCPConfiguration({ - id: 'my-mcp-config', + id: "my-mcp-config", servers: { timeMCP: { - command: 'podman', - args: ['run', '-i', '--rm', 'mcp/time'], + command: "podman", + args: ["run", "-i", "--rm", "mcp/time"], }, }, });