Skip to main content
Glama
milad13711
by milad13711

Exir MCP Server

一个多租户 Model Context Protocol 网关,位于 MCP 主机(Claude、ChatGPT 或任何其他兼容 MCP 的代理)与 Exir CRM API(底层为 Perfex CRM)之间。

                    ┌──────────────────────┐
                    │   ChatGPT / Agent     │
                    │ Claude / Other Host   │
                    └──────────┬────────────┘
                               │
                         MCP / HTTPS
                               │
                               ▼
              ┌────────────────────────────────┐
              │        Exir MCP Server          │
              │                                 │
              │ OAuth 2.1 / OIDC                │
              │ Tenant Resolver                 │
              │ Permission Engine               │
              │ Tool Registry                   │
              │ Audit Logger                    │
              │ Rate Limiter                    │
              │ Input Validation                │
              └───────────────┬─────────────────┘
                               │
                        Internal API
                               │
                               ▼
              ┌────────────────────────────────┐
              │          Exir CRM API           │
              │                                 │
              │ Customers / Leads / Sales       │
              │ Tasks / Projects / Tickets      │
              │ Invoices / Contracts / ...      │
              └───────────────┬─────────────────┘
                               │
                               ▼
                    ┌──────────────────┐
                    │ Customer Tenant   │
                    │ Data / Database   │
                    └──────────────────┘

请求流转方式

  1. 传输层(Transport) — 一个 MCP 主机发送带有 Bearer 访问令牌的 POST /mcp(Streamable HTTP)请求。

  2. OAuth 2.1 / OIDCsrc/auth/oidc.ts)— 根据身份提供方的 JWKS 验证令牌的签名、签发者、受众和过期时间。未验证的令牌永远无法到达此层之下的任何部分。

  3. 租户解析器(Tenant Resolver)src/tenant/tenantResolver.ts)— 从 已验证 令牌的一个声明中读取租户 ID,并将其映射到该租户的 Exir CRM 连接(基础 URL + API 密钥)。请求绝不会跨租户边界。

  4. 速率限制器(Rate Limiter)src/middleware/rateLimiter.ts)— 请求会按租户进行限流,这样在共享部署中,某个高请求量的调用者就不会让其他调用者得不到服务。

  5. 工具注册表(Tool Registry)src/tools/)— 该请求的 MCP 服务器通过将每个已注册的工具(src/mcp/server.ts)与以下部分包装在一起来构建:

    • 权限引擎(Permission Engine)src/permissions/permissionEngine.ts)— 将令牌的 OAuth 作用域与工具所需的作用域进行比对。

    • 输入验证(Input Validation) — 每个工具都声明一个 zod 模式;无效输入在到达 CRM 之前就会被拒绝。

    • 审计日志器(Audit Logger)src/audit/auditLogger.ts)— 每次调用(允许、拒绝、成功或错误)都会记录租户、主体、工具名称和结果。

  6. 内部 API(Internal API)src/crm/perfexClient.ts)— 一个限定租户范围的 HTTP 客户端调用真实的 Exir CRM API(Perfex CRM 的 REST API,使用 authtoken 请求头进行身份验证),并将结果沿调用链向上返回,作为该工具的输出。

Related MCP server: Nervora

项目结构

src/
  auth/oidc.ts            OAuth 2.1 / OIDC bearer-token verification
  tenant/tenantResolver.ts Tenant lookup + per-tenant CRM connection details
  permissions/permissionEngine.ts  Scope-based authorization
  audit/auditLogger.ts     Structured audit trail for every tool call
  middleware/rateLimiter.ts Per-tenant rate limiting
  crm/perfexClient.ts      Internal API client to the Exir CRM API
  tools/                   Tool Registry + one file per CRM domain
    customers.ts leads.ts tasks.ts invoices.ts
  mcp/server.ts            Wires tools -> permissions -> validation -> audit -> CRM
  http/app.ts              Express app: /healthz, POST /mcp
  index.ts                 Process entrypoint
tests/                     Vitest unit tests (permission engine, tool registry)

快速开始

npm install
cp .env.example .env   # fill in OIDC_ISSUER, CRM_API_BASE_URL, CRM_API_KEY, ...
npm run dev             # ts-node/tsx dev server on :3333

生产环境构建与运行:

npm run build
npm start

或使用 Docker:

docker compose up --build

运行测试:

npm test

添加新工具

  1. src/tools/ 下的相关文件中(或为新 CRM 域新建文件)添加一个 registry.register({...}) 调用,包含 namedescriptionrequiredScopezod inputSchema,以及一个调用 PerfexClienthandler(crm, input)

  2. 如果是新文件,请将其接入 src/tools/index.ts 中的 buildToolRegistry()

  3. tests/tools.test.ts 中添加一个测试,断言该工具已注册且其模式会拒绝无效输入。

其他任何地方都无需更改——权限控制、验证和审计由 src/mcp/server.ts 统一应用到每个已注册的工具。

多租户

src/tenant/tenantResolver.ts 附带一个 EnvTenantStore 开发回退实现,它会将每个租户 ID 解析为 .env 中的单个 CRM 连接。对于真正的多租户部署,请根据自己的租户目录(Postgres、配置服务等)实现 TenantStore 接口,将租户 ID 映射为 { baseUrl, apiKey },然后在 src/http/app.ts 中将其传入 tenantResolver(myStore)

安全说明

  • 租户 ID 只信任来自经密码学验证的访问令牌中的声明,绝不相信客户端提供的请求头,除非为受信任的内网调用者(例如本地开发)显式设置了 TENANT_HEADER_FALLBACK=true

  • 每个租户的 CRM API 密钥绝不会被记录(src/logger.ts 会对其中的 Authorization*.apiKey*.token 进行脱敏)。

  • 每次工具调用都会验证两次:一次由 MCP SDK 根据工具的 JSON 模式进行验证,另一次由处理器内部的 zod.safeParse 进行验证,之后才会发起任何 CRM API 调用。

  • 服务器以无状态方式运行(sessionIdGenerator: undefined):每个 HTTP 请求都会创建一个新的 MCP 服务器实例,作用域限定为该请求已验证的租户和权限,因此不存在可能跨租户泄漏的共享会话状态。

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    A
    maintenance
    A production-ready MCP gateway and control plane that provides credential vault, policy engine, audit logging, and managed runtime for routing tool calls between AI agents and downstream MCP servers.
    57
  • A
    license
    Not graded
    quality
    C
    maintenance
    A secure MCP gateway for enterprise AI tool execution, enabling governed invocation of business tools with authentication, RBAC, audit logging, PII redaction, and async processing.
    Apache 2.0
  • A
    license
    B
    quality
    B
    maintenance
    MCP server that connects AI assistants to the Conexa business management system, enabling CRUD operations on sales, customers, plans, contracts, charges, and more via 83 tools.
    83
    121
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A security-hardened MCP gateway that enables AI agents to call LLM APIs (Gemini, OpenAI, Claude, etc.) using ephemeral proxy tokens, eliminating exposure of real API keys.
    60
    6
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.

  • Phone, SMS & email for AI agents — one remote MCP endpoint, OAuth login, zero install.

  • MCP Server for agents to onboard, pay, and provision services autonomously with InFlow

View all MCP Connectors

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/milad13711/Exir-MCP-Connector'

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