You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will launch the MCP Inspector, allowing you to inspect and debug live MCP traffic between the Node.js server and connected clients (such as Unity or LLM IDEs).
Copy file name to clipboardExpand all lines: Editor/Resources/McpResourceBase.cs
+28-4Lines changed: 28 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
usingSystem;
2
2
usingSystem.Collections.Generic;
3
+
usingSystem.Threading.Tasks;
3
4
usingUnityEngine;
4
5
usingNewtonsoft.Json.Linq;
5
6
@@ -31,10 +32,33 @@ public abstract class McpResourceBase
31
32
publicboolIsEnabled{get;protectedset;}=true;
32
33
33
34
/// <summary>
34
-
/// Fetch the resource data with the provided parameters
35
+
/// Indicates if the fetch operation is asynchronous.
35
36
/// </summary>
36
-
/// <param name="parameters">Resource parameters as a JObject</param>
37
-
/// <returns>The result of the resource fetch as a JObject</returns>
38
-
publicabstractJObjectFetch(JObjectparameters);
37
+
publicboolIsAsync{get;protectedset;}=false;
38
+
39
+
/// <summary>
40
+
/// Synchronously fetch the resource data.
41
+
/// Implement this for synchronous resources (IsAsync = false).
42
+
/// </summary>
43
+
/// <param name="parameters">Parameters extracted from the URI or query.</param>
44
+
/// <returns>Result as JObject.</returns>
45
+
publicvirtualJObjectFetch(JObjectparameters)
46
+
{
47
+
// Default implementation throws, forcing sync resources to override.
48
+
thrownewNotImplementedException($"Synchronous Fetch not implemented for resource '{Name}'. Mark IsAsync=true and implement FetchAsync, or override Fetch.");
49
+
}
50
+
51
+
/// <summary>
52
+
/// Asynchronously fetch the resource data.
53
+
/// Implement this for asynchronous resources (IsAsync = true).
54
+
/// The implementation MUST eventually call tcs.SetResult() or tcs.SetException().
55
+
/// </summary>
56
+
/// <param name="parameters">Parameters extracted from the URI or query.</param>
57
+
/// <param name="tcs">TaskCompletionSource to set the result on.</param>
// Default implementation throws, forcing async resources to override.
61
+
tcs.SetException(newNotImplementedException($"Asynchronous FetchAsync not implemented for resource '{Name}'. Mark IsAsync=false and implement Fetch, or override FetchAsync."));
0 commit comments