Skip to main content
Glama

OneNote MCP Server

by danosb
simple-onenote.js1.76 kB
import { Client } from '@microsoft/microsoft-graph-client'; import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; // Get current directory const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Path for storing the access token const tokenFilePath = path.join(__dirname, '.access-token.txt'); async function listNotebooks() { try { // Read the access token if (!fs.existsSync(tokenFilePath)) { console.error('Access token not found. Please authenticate first.'); return; } const tokenData = fs.readFileSync(tokenFilePath, 'utf8'); let accessToken; try { // Try to parse as JSON first (new format) const parsedToken = JSON.parse(tokenData); accessToken = parsedToken.token; } catch (parseError) { // Fall back to using the raw token (old format) accessToken = tokenData; } if (!accessToken) { console.error('Access token not found in file.'); return; } // Create Microsoft Graph client const client = Client.init({ authProvider: (done) => { done(null, accessToken); } }); // Get notebooks console.log('Fetching notebooks...'); const response = await client.api('/me/onenote/notebooks').get(); console.log('\nYour OneNote Notebooks:'); console.log('======================='); if (response.value.length === 0) { console.log('No notebooks found.'); } else { response.value.forEach((notebook, index) => { console.log(`${index + 1}. ${notebook.displayName}`); }); } } catch (error) { console.error('Error listing notebooks:', error); } } // Run the function listNotebooks();

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/danosb/onenote-mcp'

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