Files · Google Gemini MCP Server for SMB Business Intelligence
88 (1 binary, 677.1 kB total)attempt 5
README.md·3227 B·markdown
markdown
# Google Gemini MCP Server for SMB Business Intelligence
> A turnkey MCP server that lets SMB teams use natural language to query their business data from HubSpot, Stripe, and Google Calendar via a secure Gemini-powered interface.
## Architecture
This solution bundles a multi-tenant MCP server that exposes business tools as MCP endpoints. It provides tenant isolation via `@reaatech/mcp-gateway-core`, budget enforcement via inline primitives, and LLM observability via Langfuse. A Next.js chat UI connects to Google Gemini (via `@ai-sdk/google`), which calls MCP tools to fetch and aggregate data from HubSpot, Stripe, and Google Calendar.
### Exposed MCP Tools
**HubSpot**
- `hubspot_search_contacts` — Search contacts by query string
- `hubspot_search_deals` — Search deals by name or amount range
- `hubspot_list_recent_deals` — List recent deals sorted by close date
**Stripe**
- `stripe_list_customers` — List customers with optional email filter
- `stripe_list_invoices` — List invoices with optional status/customer filter
- `stripe_list_subscriptions` — List subscriptions with optional status/customer filter
**Google Calendar**
- `google_calendar_list_events` — List upcoming events for a calendar
- `google_calendar_list_calendars` — List accessible calendars
## Setup
1. **Clone and install**
```bash
pnpm install
```
2. **Configure environment**
Copy `.env.example` to `.env` and fill in your credentials:
```bash
cp .env.example .env
```
Required vars: `SUPABASE_URL`, `SUPABASE_SECRET_KEY`
Optional: `HUBSPOT_ACCESS_TOKEN`, `STRIPE_SECRET_KEY`, `GEMINI_API_KEY`, etc.
3. **Run**
```bash
pnpm dev # next dev — http://localhost:3000
pnpm build # next build
pnpm test # vitest run with coverage
pnpm typecheck # tsc --noEmit
pnpm lint # eslint .
```
## Tenant Configuration
Place YAML config files under `./tenants/` (configurable via `TENANT_CONFIG_PATH`). Loaded by `loadTenantsAsync()` from `@reaatech/mcp-gateway-core`:
```yaml
tenantId: acme-corp
displayName: Acme Corp
auth:
apiKeys:
- keyHash: <sha256>
name: admin-key
rateLimits:
requestsPerMinute: 100
requestsPerDay: 10000
cache:
enabled: true
ttlSeconds: 300
allowlist:
mode: allow
tools:
- hubspot_*
- stripe_*
upstreams:
- name: main
url: https://mcp.internal.corp
```
## Prior Failure Fix
All cost calculations include null-safety guards on token counts before calling `.toFixed()`. The `GeminiPricingProvider.validateEstimateArgs()` method checks for null, undefined, NaN, and negative values before any arithmetic operations, preventing `TypeError: Cannot read properties of null (reading 'toFixed')`.
## Project Layout
```
app/ Next.js App Router pages + API routes
src/
lib/ Shared types, env config, tool definitions, handlers
lib/tool-handlers/ Business logic for HubSpot, Stripe, Google Calendar
instrumentation.ts Next.js instrumentation hook (Langfuse init)
tests/ Vitest suite (mirrors src/)
packages/ API references for every dependency
```
## License
MIT — see [LICENSE](./LICENSE).