nowgnuesLee/mcp-host-api-server
If you are the rightful owner of mcp-host-api-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
An Express-based MCP host server that integrates with OpenAI's API to facilitate AI-driven responses and tool invocation.
google-calendar
Integration with Google Calendar for scheduling and event management.
MCP Host Server
An Express-based MCP (Model Context Protocol) host server that uses OpenAI's function calls to invoke MCP server tools and generate responses.
Features
- Express-based REST API server
- AI response generation through OpenAI API
- MCP server communication and tool invocation support
- Session-based conversation history management (in-memory storage)
- Google Calendar MCP server integration
Project Structure
src/
āāā index.ts # Main server application
āāā MCP.ts # MCP server connection and tool invocation management
āāā config.ts # Configuration file loading and environment variable management
āāā types.ts # TypeScript type definitions
āāā middleware/
āāā validation.ts # Request validation middleware
Configuration Files
config.json
Defines MCP server configuration.
{
"mcp": {
"servers": [
{
"name": "google-calendar",
"command": "npx",
"args": ["@cocal/google-calendar-mcp"],
"env": {
"GOOGLE_OAUTH_CREDENTIALS": "./google_auth.json"
}
}
]
}
}
google_auth.json
Contains Google OAuth credentials. (Actual file is not included in repository for security reasons)
Environment Variables
Set the following variables in a .env
file:
OPEN_AI_KEY
: OpenAI API key
API Endpoints
POST /api/chat
Process user messages and generate AI responses.
Request Body:
{
"sessionId": "unique-session-id",
"message": "User message",
"tool": true // Whether to use tools (optional)
}
Response:
{
"message": "AI response message"
}
POST /api/chat/clear
Clear conversation history for a specific session.
Request Body:
{
"sessionId": "unique-session-id"
}
Response:
{
"message": "Chat histories cleared",
"sessionId": "unique-session-id"
}
GET /
Basic health check endpoint.
GET /api/health
Check server status.
Installation and Running
1. Install Dependencies
npm install
2. Set Environment Variables
Create a .env
file and set the required environment variables:
OPEN_AI_KEY=your-openai-api-key
3. Google Authentication Setup
Place the google_auth.json
file in the project root for Google Calendar API usage.
4. Run Development Server
npm run dev
Available Scripts
npm run dev
: Run development server (nodemon + ts-node)npm run lint
: Run ESLint checksnpm run lint:fix
: Auto-fix ESLint issuesnpm run format
: Format code with Prettiernpm run format:check
: Check Prettier formatting
Tech Stack
- Node.js: Runtime environment
- Express: Web framework
- TypeScript: Language for type safety
- OpenAI SDK: AI model API communication
- MCP SDK: Model Context Protocol implementation
- express-validator: Request validation
- dotenv: Environment variable management
Important Notes
- Currently uses in-memory storage for session information without a database
- All session data is reset when the server restarts
- Proper Google OAuth setup is required to use Google Calendar features
License
ISC