Skip to main content
Glama

Scrapbox Cosense MCP Server

by worldnine
search-pages.ts2.09 kB
import { searchPages } from "../../cosense.js"; import { formatPageOutput } from '../../utils/format.js'; export interface SearchPagesParams { query: string; projectName?: string | undefined; } export async function handleSearchPages( defaultProjectName: string, cosenseSid: string | undefined, params: SearchPagesParams ) { try { const projectName = params.projectName || defaultProjectName; const query = String(params.query); const results = await searchPages(projectName, query, cosenseSid); if (!results) { return { content: [{ type: "text", text: [ `Error: No search results`, `Operation: search_pages`, `Project: ${params.projectName || defaultProjectName}`, `Query: ${query}`, `Status: 404`, `Timestamp: ${new Date().toISOString()}` ].join('\n') }], isError: true }; } let output = [ `Project: ${projectName}`, `Search query: ${results.searchQuery}`, `Total results: ${results.count}`, `Note: Limited to 100 results. No way to fetch beyond this limit. If expected content is not found, please try refining your search query.`, '---' ].join('\n') + '\n'; output += results.pages.map((page, index) => formatPageOutput(page, index, { showMatches: true, showSnippet: true, isSearchResult: true // 検索結果であることを示すフラグを追加 }) + '\n---' ).join('\n'); return { content: [{ type: "text", text: output }] }; } catch (error) { return { content: [{ type: "text", text: [ 'Error details:', `Message: ${error instanceof Error ? error.message : 'Unknown error'}`, `Operation: search_pages`, `Project: ${params.projectName || defaultProjectName}`, `Query: ${params.query}`, `Timestamp: ${new Date().toISOString()}` ].join('\n') }], isError: true }; } }

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/worldnine/scrapbox-cosense-mcp'

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