Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.4.3"
".": "0.4.4"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.4.4 (2026-04-10)

Full Changelog: [v0.4.3...v0.4.4](https://github.com/formbricks/hub-typescript/compare/v0.4.3...v0.4.4)

### Chores

* **internal:** codegen related update ([0739fce](https://github.com/formbricks/hub-typescript/commit/0739fce1654209416037f517e244d54a92114b29))
* **internal:** fix MCP server import ordering ([7e77df7](https://github.com/formbricks/hub-typescript/commit/7e77df76e3e2b9b28123b82ae38c71e1ba0c2cb2))
* **internal:** show error causes in MCP servers when running in local mode ([e99bb20](https://github.com/formbricks/hub-typescript/commit/e99bb20da160377df4886d4fec24140e8c27439e))
* **internal:** support type annotations when running MCP in local execution mode ([819033c](https://github.com/formbricks/hub-typescript/commit/819033cee84aa1b4834cbff913c01b3ec5ce7655))
* **mcp-server:** increase local docs search result count from 5 to 10 ([79579ac](https://github.com/formbricks/hub-typescript/commit/79579ac4bf4c34ea5959dd8d01f543049b341557))
* **mcp-server:** log client info ([8683d8c](https://github.com/formbricks/hub-typescript/commit/8683d8ce060bcaf64f11948f726fc7c58049c5eb))

## 0.4.3 (2026-04-01)

Full Changelog: [v0.4.2...v0.4.3](https://github.com/formbricks/hub-typescript/compare/v0.4.2...v0.4.3)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formbricks/hub",
"version": "0.4.3",
"version": "0.4.4",
"description": "The official TypeScript library for the Formbricks Hub API",
"author": "Formbricks Hub <hola@formbricks.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dxt_version": "0.2",
"name": "@formbricks/hub-mcp",
"version": "0.4.3",
"version": "0.4.4",
"description": "The official MCP Server for the Formbricks Hub API",
"author": {
"name": "Formbricks Hub",
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formbricks/hub-mcp",
"version": "0.4.3",
"version": "0.4.4",
"description": "The official MCP Server for the Formbricks Hub API",
"author": "Formbricks Hub <hola@formbricks.com>",
"types": "dist/index.d.ts",
Expand Down
15 changes: 12 additions & 3 deletions packages/mcp-server/src/code-tool-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import ts from 'typescript';
import { WorkerOutput } from './code-tool-types';
import { FormbricksHub, ClientOptions } from '@formbricks/hub';

async function tseval(code: string) {
return import('data:application/typescript;charset=utf-8;base64,' + Buffer.from(code).toString('base64'));
}

function getRunFunctionSource(code: string): {
type: 'declaration' | 'expression';
client: string | undefined;
Expand Down Expand Up @@ -194,7 +198,8 @@ function makeSdkProxy<T extends object>(obj: T, { path, isBelievedBad = false }:

function parseError(code: string, error: unknown): string | undefined {
if (!(error instanceof Error)) return;
const message = error.name ? `${error.name}: ${error.message}` : error.message;
const cause = error.cause instanceof Error ? `: ${error.cause.message}` : '';
const message = error.name ? `${error.name}: ${error.message}${cause}` : `${error.message}${cause}`;
try {
// Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
Expand Down Expand Up @@ -250,7 +255,9 @@ const fetch = async (req: Request): Promise<Response> => {

const log_lines: string[] = [];
const err_lines: string[] = [];
const console = {
const originalConsole = globalThis.console;
globalThis.console = {
...originalConsole,
log: (...args: unknown[]) => {
log_lines.push(util.format(...args));
},
Expand All @@ -260,7 +267,7 @@ const fetch = async (req: Request): Promise<Response> => {
};
try {
let run_ = async (client: any) => {};
eval(`${code}\nrun_ = run;`);
run_ = (await tseval(`${code}\nexport default run;`)).default;
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
return Response.json({
is_error: false,
Expand All @@ -278,6 +285,8 @@ const fetch = async (req: Request): Promise<Response> => {
} satisfies WorkerOutput,
{ status: 400, statusText: 'Code execution error' },
);
} finally {
globalThis.console = originalConsole;
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/docs-search-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function searchLocal(args: Record<string, unknown>): Promise<unknown> {
query,
language,
detail,
maxResults: 5,
maxResults: 10,
}).results;
}

Expand Down
17 changes: 13 additions & 4 deletions packages/mcp-server/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ const newServer = async ({
}
}

const mcpClientInfo =
typeof req.body?.params?.clientInfo?.name === 'string' ?
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
: undefined;

await initMcpServer({
server: server,
mcpOptions: effectiveMcpOptions,
Expand All @@ -79,12 +84,13 @@ const newServer = async ({
stainlessApiKey: stainlessApiKey,
upstreamClientEnvs,
mcpSessionId: (req as any).mcpSessionId,
mcpClientInfo:
typeof req.body?.params?.clientInfo?.name === 'string' ?
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
: undefined,
mcpClientInfo,
});

if (mcpClientInfo) {
getLogger().info({ mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, 'MCP client connected');
}

return server;
};

Expand Down Expand Up @@ -154,6 +160,9 @@ export const streamableHTTPApp = ({
app.use(
pinoHttp({
logger: getLogger(),
customProps: (req) => ({
mcpSessionId: (req as any).mcpSessionId,
}),
customLogLevel: (req, res) => {
if (res.statusCode >= 500) {
return 'error';
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/instructions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import fs from 'fs/promises';
import { readEnv } from './util';
import { getLogger } from './logger';
import { readEnv } from './util';

const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes

Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const newMcpServer = async ({
new McpServer(
{
name: 'formbricks_hub_api',
version: '0.4.3',
version: '0.4.4',
},
{
instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }),
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-server/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

export const readEnv = (env: string): string | undefined => {
if (typeof (globalThis as any).process !== 'undefined') {
return (globalThis as any).process.env?.[env]?.trim();
return (globalThis as any).process.env?.[env]?.trim() || undefined;
} else if (typeof (globalThis as any).Deno !== 'undefined') {
return (globalThis as any).Deno.env?.get?.(env)?.trim();
return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
}
return;
};
Expand Down
4 changes: 2 additions & 2 deletions src/internal/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
export const readEnv = (env: string): string | undefined => {
if (typeof (globalThis as any).process !== 'undefined') {
return (globalThis as any).process.env?.[env]?.trim() ?? undefined;
return (globalThis as any).process.env?.[env]?.trim() || undefined;
}
if (typeof (globalThis as any).Deno !== 'undefined') {
return (globalThis as any).Deno.env?.get?.(env)?.trim();
return (globalThis as any).Deno.env?.get?.(env)?.trim() || undefined;
}
return undefined;
};
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.4.3'; // x-release-please-version
export const VERSION = '0.4.4'; // x-release-please-version
Loading