Skip to main content
Glama

search-notes

Search note.com articles by keyword with customizable sorting options and result limits to find relevant content quickly.

Instructions

記事を検索する

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes検索キーワード
sizeNo取得する件数(最大20)
startNo検索結果の開始位置
sortNoソート順(new: 新着順, popular: 人気順, hot: 急上昇)hot

Implementation Reference

  • The core handler function for the 'search-notes' tool. It makes an API request to note.com's search endpoint (/v3/searches?context=note), processes the response, extracts and formats notes using safeExtractData and formatNote, computes total count, and returns a success response or handles errors.
    async ({ query, size, start, sort }) => {
      try {
        const data = await noteApiRequest(`/v3/searches?context=note&q=${encodeURIComponent(query)}&size=${size}&start=${start}&sort=${sort}`);
    
        if (env.DEBUG) {
          console.error(`API Response structure for search-notes: ${JSON.stringify(data, null, 2)}`);
        }
    
        if (!data || !data.data) {
          return createErrorResponse(`APIレスポンスが空です: ${JSON.stringify(data)}`);
        }
    
        if (data.status === "error" || data.error) {
          return createErrorResponse(`APIエラー: ${JSON.stringify(data)}`);
        }
    
        const notesArray = safeExtractData(data, commonExtractors.notes);
        const totalCount = safeExtractTotal(data, notesArray.length);
        
        const formattedNotes = notesArray.map(note => formatNote(note));
    
        return createSuccessResponse({
          total: totalCount,
          notes: formattedNotes,
          rawResponse: env.DEBUG ? data : undefined
        });
      } catch (error) {
        return handleApiError(error, "記事検索");
      }
    }
  • Zod input schema defining parameters for the search-notes tool: query (required string), size, start (numbers with defaults), sort (enum with default).
    {
      query: z.string().describe("検索キーワード"),
      size: z.number().default(10).describe("取得する件数(最大20)"),
      start: z.number().default(0).describe("検索結果の開始位置"),
      sort: z.enum(["new", "popular", "hot"]).default("hot").describe("ソート順(new: 新着順, popular: 人気順, hot: 急上昇)"),
    },
  • Direct registration of the 'search-notes' tool on the MCP server instance using server.tool(), including name, description, input schema, and handler function. This is within the registerSearchTools function.
      "search-notes",
      "記事を検索する",
      {
        query: z.string().describe("検索キーワード"),
        size: z.number().default(10).describe("取得する件数(最大20)"),
        start: z.number().default(0).describe("検索結果の開始位置"),
        sort: z.enum(["new", "popular", "hot"]).default("hot").describe("ソート順(new: 新着順, popular: 人気順, hot: 急上昇)"),
      },
      async ({ query, size, start, sort }) => {
        try {
          const data = await noteApiRequest(`/v3/searches?context=note&q=${encodeURIComponent(query)}&size=${size}&start=${start}&sort=${sort}`);
    
          if (env.DEBUG) {
            console.error(`API Response structure for search-notes: ${JSON.stringify(data, null, 2)}`);
          }
    
          if (!data || !data.data) {
            return createErrorResponse(`APIレスポンスが空です: ${JSON.stringify(data)}`);
          }
    
          if (data.status === "error" || data.error) {
            return createErrorResponse(`APIエラー: ${JSON.stringify(data)}`);
          }
    
          const notesArray = safeExtractData(data, commonExtractors.notes);
          const totalCount = safeExtractTotal(data, notesArray.length);
          
          const formattedNotes = notesArray.map(note => formatNote(note));
    
          return createSuccessResponse({
            total: totalCount,
            notes: formattedNotes,
            rawResponse: env.DEBUG ? data : undefined
          });
        } catch (error) {
          return handleApiError(error, "記事検索");
        }
      }
    );
  • Top-level registration call for search tools (including search-notes) from the central registerAllTools function, invoked by main server scripts.
    registerSearchTools(server);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shimayuz/note-com-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server