formbro-mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +299 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/common.d.ts +77 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +42 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/services/api-client.d.ts +38 -0
- package/dist/services/api-client.d.ts.map +1 -0
- package/dist/services/api-client.js +125 -0
- package/dist/services/api-client.js.map +1 -0
- package/dist/tools/applicants.d.ts +6 -0
- package/dist/tools/applicants.d.ts.map +1 -0
- package/dist/tools/applicants.js +261 -0
- package/dist/tools/applicants.js.map +1 -0
- package/dist/tools/applications.d.ts +6 -0
- package/dist/tools/applications.d.ts.map +1 -0
- package/dist/tools/applications.js +225 -0
- package/dist/tools/applications.js.map +1 -0
- package/dist/tools/employers.d.ts +6 -0
- package/dist/tools/employers.d.ts.map +1 -0
- package/dist/tools/employers.js +243 -0
- package/dist/tools/employers.js.map +1 -0
- package/dist/tools/find.d.ts +6 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/find.js +122 -0
- package/dist/tools/find.js.map +1 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 FormBro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# FormBro MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/formbro-mcp-server)
|
|
4
|
+
|
|
5
|
+
MCP server for FormBro immigration management system - provides access to applicants, applications, and employers data through the Model Context Protocol.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🔍 **Smart Find Tool** - Search across applicants, applications, and employers with intelligent name matching
|
|
10
|
+
- 📋 **List Operations** - Paginated listing with search and filtering
|
|
11
|
+
- 📄 **Detail Views** - Comprehensive entity information retrieval
|
|
12
|
+
- 🔐 **Secure Authentication** - Token-based API authentication
|
|
13
|
+
- 🌐 **Dual Transport** - Supports both stdio (local) and HTTP (remote) modes
|
|
14
|
+
- 📡 **SSE Support** - Server-Sent Events for streaming responses
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Using npx (recommended)
|
|
20
|
+
npx formbro-mcp-server
|
|
21
|
+
|
|
22
|
+
# Or install globally
|
|
23
|
+
npm install -g formbro-mcp-server
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Quick Start (stdio mode)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
FORMBRO_API_URL=https://api.formbro.com \
|
|
32
|
+
FORMBRO_API_TOKEN=your-token \
|
|
33
|
+
formbro-mcp-server
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### HTTP Server Mode
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
FORMBRO_API_URL=https://api.formbro.com \
|
|
40
|
+
TRANSPORT=http \
|
|
41
|
+
PORT=3000 \
|
|
42
|
+
formbro-mcp-server
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
### Environment Variables
|
|
48
|
+
|
|
49
|
+
| Variable | Required | Description | Default |
|
|
50
|
+
|----------|----------|-------------|---------|
|
|
51
|
+
| `FORMBRO_API_URL` | Yes | Base URL of FormBro API | - |
|
|
52
|
+
| `FORMBRO_API_TOKEN` | Yes (stdio) | API token for authentication | - |
|
|
53
|
+
| `TRANSPORT` | No | Transport mode: `stdio` or `http` | `stdio` |
|
|
54
|
+
| `PORT` | No | HTTP server port (http mode only) | `3000` |
|
|
55
|
+
|
|
56
|
+
### Get Your API Token
|
|
57
|
+
|
|
58
|
+
1. Log in to FormBro
|
|
59
|
+
2. Navigate to Settings > API Tokens
|
|
60
|
+
3. Generate a new token
|
|
61
|
+
|
|
62
|
+
## Connecting from Claude
|
|
63
|
+
|
|
64
|
+
### Claude Desktop (stdio)
|
|
65
|
+
|
|
66
|
+
Add to your `claude_desktop_config.json`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"formbro": {
|
|
72
|
+
"command": "npx",
|
|
73
|
+
"args": ["-y", "formbro-mcp-server"],
|
|
74
|
+
"env": {
|
|
75
|
+
"FORMBRO_API_URL": "https://api.formbro.com",
|
|
76
|
+
"FORMBRO_API_TOKEN": "your-token"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Claude Code (HTTP)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Start HTTP server
|
|
87
|
+
FORMBRO_API_URL=https://api.formbro.com \
|
|
88
|
+
TRANSPORT=http \
|
|
89
|
+
formbro-mcp-server
|
|
90
|
+
|
|
91
|
+
# Add to Claude Code
|
|
92
|
+
claude mcp add --transport http formbro http://localhost:3000/mcp \
|
|
93
|
+
--header "Authorization: Bearer your-token"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Available Tools
|
|
97
|
+
|
|
98
|
+
### `formbro_find` (Recommended)
|
|
99
|
+
|
|
100
|
+
Smart search across all entity types with name matching and related data retrieval.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// Find applicants named "John"
|
|
104
|
+
formbro_find({ query: "John" })
|
|
105
|
+
|
|
106
|
+
// Find LMIA applications
|
|
107
|
+
formbro_find({ query: "LMIA" })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `formbro_list_applicants`
|
|
111
|
+
|
|
112
|
+
List applicants with search, program filtering, and pagination.
|
|
113
|
+
|
|
114
|
+
### `formbro_get_applicant`
|
|
115
|
+
|
|
116
|
+
Get detailed applicant information by ID.
|
|
117
|
+
|
|
118
|
+
### `formbro_list_applications`
|
|
119
|
+
|
|
120
|
+
List applications by program type (tr/pr/lmia) with status filtering.
|
|
121
|
+
|
|
122
|
+
### `formbro_get_application`
|
|
123
|
+
|
|
124
|
+
Get detailed application information by ID.
|
|
125
|
+
|
|
126
|
+
### `formbro_list_employers`
|
|
127
|
+
|
|
128
|
+
List employers with search and pagination.
|
|
129
|
+
|
|
130
|
+
### `formbro_get_employer`
|
|
131
|
+
|
|
132
|
+
Get detailed employer information by ID.
|
|
133
|
+
|
|
134
|
+
## API Response Formats
|
|
135
|
+
|
|
136
|
+
All tools support two response formats:
|
|
137
|
+
|
|
138
|
+
- `markdown` (default) - Human-readable formatted output
|
|
139
|
+
- `json` - Machine-readable structured data
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Clone the repository
|
|
145
|
+
git clone https://github.com/yourusername/formbro-mcp-server.git
|
|
146
|
+
cd formbro-mcp-server
|
|
147
|
+
|
|
148
|
+
# Install dependencies
|
|
149
|
+
pnpm install
|
|
150
|
+
|
|
151
|
+
# Build
|
|
152
|
+
pnpm build
|
|
153
|
+
|
|
154
|
+
# Run in development mode
|
|
155
|
+
pnpm dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
161
|
+
|
|
162
|
+
## Links
|
|
163
|
+
|
|
164
|
+
- [FormBro](https://formbro.com)
|
|
165
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
|
166
|
+
- [npm Package](https://www.npmjs.com/package/formbro-mcp-server)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CHARACTER_LIMIT = 25000;
|
|
2
|
+
export declare const DEFAULT_LIMIT = 20;
|
|
3
|
+
export declare const MAX_LIMIT = 100;
|
|
4
|
+
export declare const API_TIMEOUT = 30000;
|
|
5
|
+
export declare enum ResponseFormat {
|
|
6
|
+
MARKDOWN = "markdown",
|
|
7
|
+
JSON = "json"
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,QAAQ,CAAC;AAGrC,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,SAAS,MAAM,CAAC;AAG7B,eAAO,MAAM,WAAW,QAAQ,CAAC;AAGjC,oBAAY,cAAc;IACxB,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// FormBro MCP Server Constants
|
|
2
|
+
// Maximum response size in characters
|
|
3
|
+
export const CHARACTER_LIMIT = 25000;
|
|
4
|
+
// Default pagination settings
|
|
5
|
+
export const DEFAULT_LIMIT = 20;
|
|
6
|
+
export const MAX_LIMIT = 100;
|
|
7
|
+
// API timeout in milliseconds
|
|
8
|
+
export const API_TIMEOUT = 30000;
|
|
9
|
+
// Response format options
|
|
10
|
+
export var ResponseFormat;
|
|
11
|
+
(function (ResponseFormat) {
|
|
12
|
+
ResponseFormat["MARKDOWN"] = "markdown";
|
|
13
|
+
ResponseFormat["JSON"] = "json";
|
|
14
|
+
})(ResponseFormat || (ResponseFormat = {}));
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,sCAAsC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC,8BAA8B;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE7B,8BAA8B;AAC9B,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,0BAA0B;AAC1B,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* FormBro MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Provides access to FormBro immigration management system data through MCP protocol.
|
|
6
|
+
* Supports both HTTP (for remote access) and stdio (for local CLI) transports.
|
|
7
|
+
*
|
|
8
|
+
* Environment Variables:
|
|
9
|
+
* FORMBRO_API_URL - Base URL of FormBro API (e.g., https://api.formbro.com)
|
|
10
|
+
* FORMBRO_API_TOKEN - Your FormBro API token for authentication
|
|
11
|
+
* TRANSPORT - Transport mode: 'http' or 'stdio' (default: 'stdio')
|
|
12
|
+
* PORT - HTTP server port (default: 3000, only for HTTP transport)
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* FormBro MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Provides access to FormBro immigration management system data through MCP protocol.
|
|
6
|
+
* Supports both HTTP (for remote access) and stdio (for local CLI) transports.
|
|
7
|
+
*
|
|
8
|
+
* Environment Variables:
|
|
9
|
+
* FORMBRO_API_URL - Base URL of FormBro API (e.g., https://api.formbro.com)
|
|
10
|
+
* FORMBRO_API_TOKEN - Your FormBro API token for authentication
|
|
11
|
+
* TRANSPORT - Transport mode: 'http' or 'stdio' (default: 'stdio')
|
|
12
|
+
* PORT - HTTP server port (default: 3000, only for HTTP transport)
|
|
13
|
+
*/
|
|
14
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
15
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
16
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
17
|
+
import express from "express";
|
|
18
|
+
import http from "http";
|
|
19
|
+
import { initializeApiClient, setBaseUrl, createApiClientWithToken, runWithApiClient, isApiClientConfigured, getBaseUrl } from "./services/api-client.js";
|
|
20
|
+
import { registerApplicantTools } from "./tools/applicants.js";
|
|
21
|
+
import { registerApplicationTools } from "./tools/applications.js";
|
|
22
|
+
import { registerEmployerTools } from "./tools/employers.js";
|
|
23
|
+
import { registerFindTool } from "./tools/find.js";
|
|
24
|
+
// Server configuration
|
|
25
|
+
const SERVER_NAME = "formbro-mcp-server";
|
|
26
|
+
const SERVER_VERSION = "1.0.0";
|
|
27
|
+
/**
|
|
28
|
+
* Validate required environment variables for STDIO mode
|
|
29
|
+
*/
|
|
30
|
+
function validateEnvironmentStdio() {
|
|
31
|
+
const apiUrl = process.env.FORMBRO_API_URL;
|
|
32
|
+
const apiToken = process.env.FORMBRO_API_TOKEN;
|
|
33
|
+
if (!apiUrl) {
|
|
34
|
+
console.error("ERROR: FORMBRO_API_URL environment variable is required");
|
|
35
|
+
console.error("Example: export FORMBRO_API_URL=https://api.formbro.com");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
if (!apiToken) {
|
|
39
|
+
console.error("ERROR: FORMBRO_API_TOKEN environment variable is required");
|
|
40
|
+
console.error("Get your API token from FormBro settings");
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
return { apiUrl, apiToken };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validate required environment variables for HTTP mode
|
|
47
|
+
* Token is provided per-request via Authorization header
|
|
48
|
+
*/
|
|
49
|
+
function validateEnvironmentHttp() {
|
|
50
|
+
const apiUrl = process.env.FORMBRO_API_URL;
|
|
51
|
+
if (!apiUrl) {
|
|
52
|
+
console.error("ERROR: FORMBRO_API_URL environment variable is required");
|
|
53
|
+
console.error("Example: export FORMBRO_API_URL=https://api.formbro.com");
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
return { apiUrl };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create and configure the MCP server
|
|
60
|
+
*/
|
|
61
|
+
function createServer() {
|
|
62
|
+
const server = new McpServer({
|
|
63
|
+
name: SERVER_NAME,
|
|
64
|
+
version: SERVER_VERSION
|
|
65
|
+
});
|
|
66
|
+
// Register all tools
|
|
67
|
+
registerFindTool(server); // Smart find tool - recommended for most queries
|
|
68
|
+
registerApplicantTools(server);
|
|
69
|
+
registerApplicationTools(server);
|
|
70
|
+
registerEmployerTools(server);
|
|
71
|
+
return server;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Run server with stdio transport (for local CLI usage)
|
|
75
|
+
*/
|
|
76
|
+
async function runStdio() {
|
|
77
|
+
const { apiUrl, apiToken } = validateEnvironmentStdio();
|
|
78
|
+
initializeApiClient(apiUrl, apiToken);
|
|
79
|
+
const server = createServer();
|
|
80
|
+
const transport = new StdioServerTransport();
|
|
81
|
+
await server.connect(transport);
|
|
82
|
+
console.error(`${SERVER_NAME} v${SERVER_VERSION} running via stdio`);
|
|
83
|
+
console.error(`Connected to FormBro API at ${apiUrl}`);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Extract token from Authorization header
|
|
87
|
+
* Supports both formats:
|
|
88
|
+
* - "Bearer fb_xxx" -> returns "fb_xxx"
|
|
89
|
+
* - "fb_xxx" -> returns "fb_xxx"
|
|
90
|
+
*/
|
|
91
|
+
function extractToken(req) {
|
|
92
|
+
const authHeader = req.headers.authorization;
|
|
93
|
+
if (!authHeader)
|
|
94
|
+
return null;
|
|
95
|
+
// Check for "Bearer xxx" format
|
|
96
|
+
const parts = authHeader.split(" ");
|
|
97
|
+
if (parts.length === 2 && parts[0].toLowerCase() === "bearer") {
|
|
98
|
+
return parts[1];
|
|
99
|
+
}
|
|
100
|
+
// Support direct token format (no Bearer prefix)
|
|
101
|
+
if (parts.length === 1 && authHeader.startsWith("fb_")) {
|
|
102
|
+
return authHeader;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Run server with HTTP transport (for remote access)
|
|
108
|
+
*/
|
|
109
|
+
async function runHttp() {
|
|
110
|
+
const { apiUrl } = validateEnvironmentHttp();
|
|
111
|
+
setBaseUrl(apiUrl);
|
|
112
|
+
const app = express();
|
|
113
|
+
app.use(express.json());
|
|
114
|
+
// Health check endpoint
|
|
115
|
+
app.get("/health", (_req, res) => {
|
|
116
|
+
res.json({
|
|
117
|
+
status: "ok",
|
|
118
|
+
server: SERVER_NAME,
|
|
119
|
+
version: SERVER_VERSION,
|
|
120
|
+
apiUrl: getBaseUrl(),
|
|
121
|
+
apiConfigured: isApiClientConfigured()
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
// MCP endpoint - Streamable HTTP transport
|
|
125
|
+
app.post("/mcp", async (req, res) => {
|
|
126
|
+
try {
|
|
127
|
+
// Extract token from Authorization header
|
|
128
|
+
const token = extractToken(req);
|
|
129
|
+
if (!token) {
|
|
130
|
+
res.status(401).json({
|
|
131
|
+
error: "Unauthorized",
|
|
132
|
+
message: "Missing Authorization header. Include 'Authorization: Bearer YOUR_FORMBRO_API_TOKEN' in your request."
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Create API client with the provided token
|
|
137
|
+
const apiClient = createApiClientWithToken(token);
|
|
138
|
+
// Run the MCP request with the token-specific API client
|
|
139
|
+
await runWithApiClient(apiClient, async () => {
|
|
140
|
+
const server = createServer();
|
|
141
|
+
// Create new transport for each request (stateless)
|
|
142
|
+
const transport = new StreamableHTTPServerTransport({
|
|
143
|
+
sessionIdGenerator: undefined,
|
|
144
|
+
enableJsonResponse: true
|
|
145
|
+
});
|
|
146
|
+
res.on("close", () => transport.close());
|
|
147
|
+
await server.connect(transport);
|
|
148
|
+
await transport.handleRequest(req, res, req.body);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error("MCP request error:", error);
|
|
153
|
+
if (!res.headersSent) {
|
|
154
|
+
res.status(500).json({
|
|
155
|
+
error: "Internal server error",
|
|
156
|
+
message: error instanceof Error ? error.message : String(error)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
// Handle GET requests with method info
|
|
162
|
+
app.get("/mcp", (_req, res) => {
|
|
163
|
+
res.json({
|
|
164
|
+
name: SERVER_NAME,
|
|
165
|
+
version: SERVER_VERSION,
|
|
166
|
+
description: "FormBro MCP Server - Immigration Management System",
|
|
167
|
+
transport: "Streamable HTTP",
|
|
168
|
+
method: "POST /mcp",
|
|
169
|
+
tools: [
|
|
170
|
+
"formbro_find", // Recommended: Smart search with name matching and related data
|
|
171
|
+
"formbro_list_applicants",
|
|
172
|
+
"formbro_get_applicant",
|
|
173
|
+
"formbro_list_applications",
|
|
174
|
+
"formbro_get_application",
|
|
175
|
+
"formbro_list_employers",
|
|
176
|
+
"formbro_get_employer"
|
|
177
|
+
]
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
// Support both MCP_PORT (from env files) and PORT (generic)
|
|
181
|
+
const port = parseInt(process.env.MCP_PORT || process.env.PORT || "3000", 10);
|
|
182
|
+
// Create raw HTTP server to inject Accept header before Express processes the request
|
|
183
|
+
// This is necessary because the MCP SDK's StreamableHTTPServerTransport requires
|
|
184
|
+
// the Accept header to include both application/json and text/event-stream,
|
|
185
|
+
// but Claude Code's HTTP client may not send this header correctly
|
|
186
|
+
const server = http.createServer((req, res) => {
|
|
187
|
+
// Inject Accept header for MCP POST requests if missing
|
|
188
|
+
if (req.method === "POST" && req.url?.startsWith("/mcp")) {
|
|
189
|
+
const accept = req.headers.accept || "";
|
|
190
|
+
if (!accept.includes("text/event-stream")) {
|
|
191
|
+
const newAccept = "application/json, text/event-stream";
|
|
192
|
+
// Modify headers object
|
|
193
|
+
req.headers.accept = newAccept;
|
|
194
|
+
// Also modify rawHeaders array (used by @hono/node-server)
|
|
195
|
+
const rawHeaders = req.rawHeaders;
|
|
196
|
+
let found = false;
|
|
197
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
198
|
+
if (rawHeaders[i].toLowerCase() === "accept") {
|
|
199
|
+
rawHeaders[i + 1] = newAccept;
|
|
200
|
+
found = true;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// If Accept header doesn't exist, add it
|
|
205
|
+
if (!found) {
|
|
206
|
+
rawHeaders.push("Accept", newAccept);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Pass to Express
|
|
211
|
+
app(req, res);
|
|
212
|
+
});
|
|
213
|
+
server.listen(port, () => {
|
|
214
|
+
console.error(`${SERVER_NAME} v${SERVER_VERSION} running on http://localhost:${port}/mcp`);
|
|
215
|
+
console.error(`Backend API: ${apiUrl}`);
|
|
216
|
+
console.error("");
|
|
217
|
+
console.error("Authentication: Each request must include 'Authorization: Bearer YOUR_FORMBRO_API_TOKEN' header.");
|
|
218
|
+
console.error("Get your API token from FormBro Settings > API Tokens");
|
|
219
|
+
console.error("");
|
|
220
|
+
console.error("To connect from Claude Code, add the server with your token:");
|
|
221
|
+
console.error(` claude mcp add --transport http formbro http://localhost:${port}/mcp --header "Authorization: Bearer YOUR_TOKEN"`);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Print usage information
|
|
226
|
+
*/
|
|
227
|
+
function printHelp() {
|
|
228
|
+
console.log(`
|
|
229
|
+
${SERVER_NAME} v${SERVER_VERSION}
|
|
230
|
+
FormBro MCP Server - Access immigration data from Claude Code/Desktop
|
|
231
|
+
|
|
232
|
+
USAGE:
|
|
233
|
+
formbro-mcp-server [options]
|
|
234
|
+
|
|
235
|
+
ENVIRONMENT VARIABLES:
|
|
236
|
+
FORMBRO_API_URL Base URL of FormBro API (required)
|
|
237
|
+
Example: https://api.formbro.com
|
|
238
|
+
|
|
239
|
+
FORMBRO_API_TOKEN Your FormBro API token (required)
|
|
240
|
+
Get this from FormBro settings
|
|
241
|
+
|
|
242
|
+
TRANSPORT Transport mode (optional, default: stdio)
|
|
243
|
+
- stdio: For local CLI integration
|
|
244
|
+
- http: For remote HTTP access
|
|
245
|
+
|
|
246
|
+
PORT HTTP server port (optional, default: 3000)
|
|
247
|
+
Only used when TRANSPORT=http
|
|
248
|
+
|
|
249
|
+
EXAMPLES:
|
|
250
|
+
# Run with stdio transport (for Claude Desktop)
|
|
251
|
+
FORMBRO_API_URL=https://api.formbro.com \\
|
|
252
|
+
FORMBRO_API_TOKEN=your-token \\
|
|
253
|
+
formbro-mcp-server
|
|
254
|
+
|
|
255
|
+
# Run with HTTP transport (for remote access)
|
|
256
|
+
FORMBRO_API_URL=https://api.formbro.com \\
|
|
257
|
+
FORMBRO_API_TOKEN=your-token \\
|
|
258
|
+
TRANSPORT=http \\
|
|
259
|
+
PORT=8080 \\
|
|
260
|
+
formbro-mcp-server
|
|
261
|
+
|
|
262
|
+
AVAILABLE TOOLS:
|
|
263
|
+
formbro_find [RECOMMENDED] Smart search with name matching and related data
|
|
264
|
+
formbro_list_applicants List applicants with search and pagination
|
|
265
|
+
formbro_get_applicant Get detailed applicant information
|
|
266
|
+
formbro_list_applications List applications by program type
|
|
267
|
+
formbro_get_application Get detailed application information
|
|
268
|
+
formbro_list_employers List employers with search and pagination
|
|
269
|
+
formbro_get_employer Get detailed employer information
|
|
270
|
+
|
|
271
|
+
CONNECTING FROM CLAUDE CODE:
|
|
272
|
+
# For HTTP transport
|
|
273
|
+
claude mcp add --transport http formbro http://localhost:3000/mcp
|
|
274
|
+
|
|
275
|
+
# For stdio transport
|
|
276
|
+
claude mcp add --transport stdio formbro -- \\
|
|
277
|
+
env FORMBRO_API_URL=... FORMBRO_API_TOKEN=... formbro-mcp-server
|
|
278
|
+
`);
|
|
279
|
+
}
|
|
280
|
+
// Main entry point
|
|
281
|
+
const args = process.argv.slice(2);
|
|
282
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
283
|
+
printHelp();
|
|
284
|
+
process.exit(0);
|
|
285
|
+
}
|
|
286
|
+
const transport = process.env.TRANSPORT || "stdio";
|
|
287
|
+
if (transport === "http") {
|
|
288
|
+
runHttp().catch((error) => {
|
|
289
|
+
console.error("Server error:", error);
|
|
290
|
+
process.exit(1);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
runStdio().catch((error) => {
|
|
295
|
+
console.error("Server error:", error);
|
|
296
|
+
process.exit(1);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,OAA4C,MAAM,SAAS,CAAC;AACnE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,uBAAuB;AACvB,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B;;GAEG;AACH,SAAS,wBAAwB;IAC/B,M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CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ResponseFormat } from "../constants.js";
|
|
3
|
+
export declare const PaginationSchema: z.ZodObject<{
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
|
+
limit: number;
|
|
8
|
+
offset: number;
|
|
9
|
+
}, {
|
|
10
|
+
limit?: number | undefined;
|
|
11
|
+
offset?: number | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const ResponseFormatSchema: z.ZodObject<{
|
|
14
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof ResponseFormat>>;
|
|
15
|
+
}, "strict", z.ZodTypeAny, {
|
|
16
|
+
response_format: ResponseFormat;
|
|
17
|
+
}, {
|
|
18
|
+
response_format?: ResponseFormat | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const ListOptionsSchema: z.ZodObject<{
|
|
21
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
} & {
|
|
24
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof ResponseFormat>>;
|
|
25
|
+
}, "strict", z.ZodTypeAny, {
|
|
26
|
+
limit: number;
|
|
27
|
+
offset: number;
|
|
28
|
+
response_format: ResponseFormat;
|
|
29
|
+
}, {
|
|
30
|
+
limit?: number | undefined;
|
|
31
|
+
offset?: number | undefined;
|
|
32
|
+
response_format?: ResponseFormat | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const IdSchema: z.ZodObject<{
|
|
35
|
+
id: z.ZodString;
|
|
36
|
+
}, "strict", z.ZodTypeAny, {
|
|
37
|
+
id: string;
|
|
38
|
+
}, {
|
|
39
|
+
id: string;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const IdWithFormatSchema: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
} & {
|
|
44
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof ResponseFormat>>;
|
|
45
|
+
}, "strict", z.ZodTypeAny, {
|
|
46
|
+
response_format: ResponseFormat;
|
|
47
|
+
id: string;
|
|
48
|
+
}, {
|
|
49
|
+
id: string;
|
|
50
|
+
response_format?: ResponseFormat | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const SearchSchema: z.ZodObject<{
|
|
53
|
+
search: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, "strict", z.ZodTypeAny, {
|
|
55
|
+
search?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
search?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
export declare const ListWithSearchSchema: z.ZodObject<{
|
|
60
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
61
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
62
|
+
} & {
|
|
63
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof ResponseFormat>>;
|
|
64
|
+
} & {
|
|
65
|
+
search: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strict", z.ZodTypeAny, {
|
|
67
|
+
limit: number;
|
|
68
|
+
offset: number;
|
|
69
|
+
response_format: ResponseFormat;
|
|
70
|
+
search?: string | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
limit?: number | undefined;
|
|
73
|
+
offset?: number | undefined;
|
|
74
|
+
response_format?: ResponseFormat | undefined;
|
|
75
|
+
search?: string | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAG3E,eAAO,MAAM,gBAAgB;;;;;;;;;EAYlB,CAAC;AAGZ,eAAO,MAAM,oBAAoB;;;;;;EAItB,CAAC;AAGZ,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;EAA+C,CAAC;AAG9E,eAAO,MAAM,QAAQ;;;;;;EAIV,CAAC;AAGZ,eAAO,MAAM,kBAAkB;;;;;;;;;;EAAuC,CAAC;AAGvE,eAAO,MAAM,YAAY;;;;;;EAId,CAAC;AAGZ,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;EAAwC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Common Zod Schemas for FormBro MCP Server
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ResponseFormat, DEFAULT_LIMIT, MAX_LIMIT } from "../constants.js";
|
|
4
|
+
// Pagination schema
|
|
5
|
+
export const PaginationSchema = z.object({
|
|
6
|
+
limit: z.number()
|
|
7
|
+
.int()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(MAX_LIMIT)
|
|
10
|
+
.default(DEFAULT_LIMIT)
|
|
11
|
+
.describe("Maximum number of results to return (1-100, default: 20)"),
|
|
12
|
+
offset: z.number()
|
|
13
|
+
.int()
|
|
14
|
+
.min(0)
|
|
15
|
+
.default(0)
|
|
16
|
+
.describe("Number of results to skip for pagination")
|
|
17
|
+
}).strict();
|
|
18
|
+
// Response format schema
|
|
19
|
+
export const ResponseFormatSchema = z.object({
|
|
20
|
+
response_format: z.nativeEnum(ResponseFormat)
|
|
21
|
+
.default(ResponseFormat.MARKDOWN)
|
|
22
|
+
.describe("Output format: 'markdown' for human-readable or 'json' for machine-readable")
|
|
23
|
+
}).strict();
|
|
24
|
+
// Combined pagination and format schema
|
|
25
|
+
export const ListOptionsSchema = PaginationSchema.merge(ResponseFormatSchema);
|
|
26
|
+
// ID parameter schema
|
|
27
|
+
export const IdSchema = z.object({
|
|
28
|
+
id: z.string()
|
|
29
|
+
.min(1)
|
|
30
|
+
.describe("The unique identifier (MongoDB ObjectId)")
|
|
31
|
+
}).strict();
|
|
32
|
+
// ID with format schema
|
|
33
|
+
export const IdWithFormatSchema = IdSchema.merge(ResponseFormatSchema);
|
|
34
|
+
// Search schema
|
|
35
|
+
export const SearchSchema = z.object({
|
|
36
|
+
search: z.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Search query to filter results (searches name, email, etc.)")
|
|
39
|
+
}).strict();
|
|
40
|
+
// List with search schema
|
|
41
|
+
export const ListWithSearchSchema = ListOptionsSchema.merge(SearchSchema);
|
|
42
|
+
//# sourceMappingURL=common.js.map
|