fa-mcp-sdk 0.12.8 → 0.12.10

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.
@@ -58,7 +58,7 @@
58
58
  "dependencies": {
59
59
  "@modelcontextprotocol/sdk": "^1.29.0",
60
60
  "dotenv": "^17.4.1",
61
- "fa-mcp-sdk": "^0.12.8"
61
+ "fa-mcp-sdk": "^0.12.10"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/express": "^5.0.6",
@@ -586,6 +586,7 @@ class McpAgentTester {
586
586
  this.usedHeaders = [];
587
587
  this.pendingConnectionData = null;
588
588
  this._headersUpdateTimer = null;
589
+ this._headersApplyPromise = null;
589
590
  this.defaultMcpUrl = null;
590
591
  this.authEnabled = false;
591
592
  this.configHttpHeaders = {};
@@ -1075,6 +1076,8 @@ class McpAgentTester {
1075
1076
  return;
1076
1077
  }
1077
1078
 
1079
+ await this.flushPendingHeaders();
1080
+
1078
1081
  try {
1079
1082
  const resp = await apiFetch(`${API_BASE}/api/mcp/call-tool`, {
1080
1083
  method: 'POST',
@@ -2016,10 +2019,36 @@ class McpAgentTester {
2016
2019
  clearTimeout(this._headersUpdateTimer);
2017
2020
  }
2018
2021
  this._headersUpdateTimer = setTimeout(() => {
2019
- this.applyHeadersUpdate().catch((err) => console.warn('Apply headers failed:', err));
2022
+ this._headersUpdateTimer = null;
2023
+ this._runHeadersUpdate();
2020
2024
  }, 600);
2021
2025
  }
2022
2026
 
2027
+ _runHeadersUpdate() {
2028
+ this._headersApplyPromise = this.applyHeadersUpdate()
2029
+ .catch((err) => console.warn('Apply headers failed:', err))
2030
+ .finally(() => {
2031
+ this._headersApplyPromise = null;
2032
+ });
2033
+ return this._headersApplyPromise;
2034
+ }
2035
+
2036
+ // Flush any pending (debounced or in-flight) header update so a direct tool
2037
+ // call sees the latest header values on the server. Without this, a fast
2038
+ // "Send Request" click races the 600 ms debounce and the call goes out with
2039
+ // the previously applied (or empty) headers — e.g. a missing
2040
+ // x-on-behalf-of-user yields MISSING_USER_IDENTITY.
2041
+ async flushPendingHeaders() {
2042
+ if (this._headersUpdateTimer) {
2043
+ clearTimeout(this._headersUpdateTimer);
2044
+ this._headersUpdateTimer = null;
2045
+ this._runHeadersUpdate();
2046
+ }
2047
+ if (this._headersApplyPromise) {
2048
+ await this._headersApplyPromise;
2049
+ }
2050
+ }
2051
+
2023
2052
  async applyHeadersUpdate() {
2024
2053
  if (!this.currentServer || !this.currentServer.name) {
2025
2054
  return;
@@ -3596,6 +3625,9 @@ class McpAgentTester {
3596
3625
  this.ttResponseContent.innerHTML = '';
3597
3626
  this.ttResponseContent.textContent = '⏳ Waiting for response…';
3598
3627
 
3628
+ // Ensure debounced header edits reach the server before the direct call.
3629
+ await this.flushPendingHeaders();
3630
+
3599
3631
  const startedAt = performance.now();
3600
3632
  try {
3601
3633
  const response = await apiFetch(`${API_BASE}/api/mcp/call-tool`, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fa-mcp-sdk",
3
3
  "productName": "FA MCP SDK",
4
- "version": "0.12.8",
4
+ "version": "0.12.10",
5
5
  "description": "Core infrastructure and templates for building Model Context Protocol (MCP) servers with TypeScript",
6
6
  "type": "module",
7
7
  "main": "dist/core/index.js",