Skip to main content
Glama
search.ts1.22 kB
import { callGraphApi } from '../utils/httpClient.js'; import { getAuthManager, REQUIRED_SCOPES } from '../auth/identity.js'; import { info } from '../utils/logger.js'; /** * Copilot Search API Response Types */ export interface SearchHit { webUrl: string; preview: string; resourceType: string; } export interface SearchResponse { totalCount: number; searchHits: SearchHit[]; } /** * Call Microsoft 365 Copilot Search API * Searches across SharePoint, OneDrive, and other M365 content * * @param query - Natural language search query from the user * @returns Search response with document links and previews */ export async function copilotSearch( query: string ): Promise<SearchResponse> { info('Calling Copilot Search API', { queryLength: query.length, }); // Get access token const authManager = getAuthManager(); const accessToken = await authManager.getAccessToken(REQUIRED_SCOPES); // Call Search API const result = await callGraphApi( '/beta/copilot/search', 'POST', { query }, accessToken ); info('Copilot Search API call succeeded', { totalCount: result.totalCount, hitsReturned: result.searchHits?.length || 0, }); return result; }

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/chenxizhang/m365copilot-mcp'

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