office-mcp
Version:
A Model Context Protocol server for Microsoft Office document manipulation
46 lines (36 loc) • 1.18 kB
JavaScript
// Entry point for the Office MCP npm package
// This file provides programmatic access to the Office MCP server
const { spawn } = require('child_process');
const path = require('path');
/**
* Start the Office MCP server
* @param {Object} options - Configuration options
* @param {boolean} options.stdio - Whether to use stdio mode (default: true)
* @param {string[]} options.args - Additional arguments to pass to the server
* @returns {ChildProcess} The spawned MCP server process
*/
function startOfficeMcp(options = {}) {
const { stdio = true, args = [] } = options;
const wrapperPath = path.join(__dirname, 'bin', 'office-mcp');
const child = spawn(wrapperPath, args, {
stdio: stdio ? 'inherit' : 'pipe'
});
return child;
}
// If called directly (not imported), start the server
if (require.main === module) {
const server = startOfficeMcp({
args: process.argv.slice(2)
});
server.on('exit', (code) => {
process.exit(code || 0);
});
server.on('error', (err) => {
console.error('Failed to start Office MCP server:', err);
process.exit(1);
});
}
module.exports = {
startOfficeMcp
};