Skip to content

Commit 9203216

Browse files
author
flowcore-platform
committed
feat(build): ✨ Add shebang line to build process and create add-shebang script
1 parent d389d81 commit 9203216

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"README.md"
1515
],
1616
"scripts": {
17-
"build": "bun build ./src/index.ts --outdir ./dist --target node && bun run copy-files",
17+
"build": "bun build ./src/index.ts --outdir ./dist --target node && bun run copy-files && bun run add-shebang",
1818
"copy-files": "bun run scripts/copy-files.ts",
19+
"add-shebang": "bun run scripts/add-shebang.ts",
1920
"prepublishOnly": "bun run build",
2021
"inspect": "bunx @modelcontextprotocol/inspector bun src/index.ts",
2122
"lint": "biome lint",

scripts/add-shebang.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bun
2+
/**
3+
* This script adds a shebang line to the dist/index.js file
4+
* It's used as part of the build process
5+
*/
6+
7+
import { readFile, writeFile } from "node:fs/promises"
8+
import { join } from "node:path"
9+
10+
// Read the built file
11+
const filePath = join("dist", "index.js")
12+
const content = await readFile(filePath, "utf-8")
13+
14+
// Add shebang line if it doesn't exist
15+
if (!content.startsWith("#!/usr/bin/env node")) {
16+
const newContent = `#!/usr/bin/env node\n${content}`
17+
await writeFile(filePath, newContent)
18+
console.log("✅ Added shebang line to dist/index.js")
19+
} else {
20+
console.log("✅ Shebang line already exists in dist/index.js")
21+
}

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#!/usr/bin/env node
2+
13
import { FlowcoreClient } from "@flowcore/sdk"
24
import { OidcClient } from "@flowcore/sdk-oidc-client"
35
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js"
46
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
57
import { parseArgs } from "node:util"
68
import { z } from "zod"
7-
// Import package.json for version
89
import pkg from "../package.json"
910
import { dataCoreResource, eventTypeResource, flowTypeResource, tenantResource } from "./resources"
1011
import {
@@ -21,7 +22,8 @@ const OIDC_ISSUER = "https://auth.flowcore.io/realms/flowcore/.well-known/openid
2122

2223
// Parse command line arguments
2324
const { values, positionals } = parseArgs({
24-
args: Bun.argv,
25+
// Use process.argv if Bun is not available
26+
args: typeof Bun !== "undefined" ? Bun.argv : process.argv,
2527
options: {
2628
serviceAccountId: { type: "string" },
2729
serviceAccountKey: { type: "string" },
@@ -53,8 +55,7 @@ const flowcoreClient = new FlowcoreClient({
5355
const server = new McpServer({
5456
name: "Flowcore Platform",
5557
version: pkg.version,
56-
description:
57-
`## Flowcore Platform MCP Server
58+
description: `## Flowcore Platform MCP Server
5859
An MCP server for managing and interacting with Flowcore Platform. For information on the details of the flowcore platform, you can check the Flowcore Platform Data Core, as it houses all actions that have happened in the platform. These actions are called events and are the main building blocks of the platform and housed within the data core inside the event type. The hirearchy of the platform is as follows: Users -> Tenant -> Data Core -> Flow Type -> Event Type -> Events. Tenants and organizations are the same thing in the platform, we are transitioning to use the term tenant. The events are stored in time buckets, and can be fetched by using the get_time_buckets tool. When you fetch events from a time bucket, you can use the cursor to paginate through the events. The default page size is 500 events per page, but you can change this by using the pageSize parameter. Also, the order of the events fetched from each time bucket is ascending by default, but you can change this by using the order parameter but keep in mind that when using desc, pagination and filters are not possible.
5960
6061
## When asking for information in the Flowcore Platform

0 commit comments

Comments
 (0)