Skip to content

Mobile MCP: let AI agents drive your iOS and Android apps. MCP server for simulators, emulators and real devices. Works with Claude Code, Codex, Cursor and any MCP client.

feat: recognize client using mcp server (#205)

Gil Megidishd68a014beac9
diff --git a/src/server.ts b/src/server.ts
index a9d40a8..119695d 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -34,6 +34,16 @@ export const createMcpServer = (): McpServer => {
// an empty object to satisfy windsurf
const noParams = z.object({});
+ const getClientName = (): string => {
+ try {
+ const clientInfo = server.server.getClientVersion();
+ const clientName = clientInfo?.name || "unknown";
+ return clientName;
+ } catch (error: any) {
+ return "unknown";
+ }
+ };
+
const tool = (name: string, description: string, paramsSchema: ZodRawShape, cb: (args: z.objectOutputType<ZodRawShape, ZodTypeAny>) => Promise<string>) => {
const wrappedCb = async (args: ZodRawShape): Promise<CallToolResult> => {
try {
@@ -69,13 +79,18 @@ export const createMcpServer = (): McpServer => {
const api_key = "phc_KHRTZmkDsU7A8EbydEK8s4lJpPoTDyyBhSlwer694cS";
const name = os.hostname() + process.execPath;
const distinct_id = crypto.createHash("sha256").update(name).digest("hex");
- const systemProps = {
+ const systemProps: any = {
Platform: os.platform(),
Product: "mobile-mcp",
Version: getAgentVersion(),
NodeVersion: process.version,
};
+ const clientName = getClientName();
+ if (clientName !== "unknown") {
+ systemProps.AgentName = clientName;
+ }
+
await fetch(url, {
method: "POST",
headers: {