[
  {
    "path": ".github/workflows/build.yml",
    "content": "name: Build with Maven\n\non:\n  push:\n    branches: [ \"main\" ]\n  pull_request:\n    branches: [ \"main\" ]\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    env:\n      GHIDRA_VERSION: 11.3.2\n      GHIDRA_DATE: 20250415\n      GHIDRA_LIBS: >-\n        Features/Base/lib/Base.jar\n        Features/Decompiler/lib/Decompiler.jar\n        Framework/Docking/lib/Docking.jar\n        Framework/Generic/lib/Generic.jar\n        Framework/Project/lib/Project.jar\n        Framework/SoftwareModeling/lib/SoftwareModeling.jar\n        Framework/Utility/lib/Utility.jar\n        Framework/Gui/lib/Gui.jar\n\n    steps:\n    - uses: actions/checkout@v4\n    - name: Set up JDK 21\n      uses: actions/setup-java@v4\n      with:\n        java-version: '21'\n        distribution: 'temurin'\n        cache: maven\n\n    - name: Download Ghidra\n      run: |\n        wget --no-verbose -O ghidra.zip https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${{ env.GHIDRA_VERSION }}_build/ghidra_${{ env.GHIDRA_VERSION }}_PUBLIC_${{ env.GHIDRA_DATE }}.zip\n        7z x -bd ghidra.zip\n\n    - name: Copy Ghidra libs\n      run: |\n        mkdir -p ./lib\n        for libfile in ${{ env.GHIDRA_LIBS }}\n          do echo \"Copying ${libfile} to lib/\"\n          cp ghidra_${{ env.GHIDRA_VERSION }}_PUBLIC/Ghidra/${libfile} ./lib/\n        done\n\n    - name: Build with Maven\n      run: mvn clean package assembly:single\n\n    - name: Assemble release directory\n      run: |\n        mkdir release\n        cp target/GhidraMCP-*-SNAPSHOT.zip release/\n        cp bridge_mcp_ghidra.py release/\n\n    - name: Upload artifact\n      uses: actions/upload-artifact@v4\n      with:\n        name: GhidraMCP-artifact\n        path: |\n          release/*\n"
  },
  {
    "path": ".gitignore",
    "content": "# Maven target directory\n/target/\n\n# Compiled class files\n*.class\n\n# Logs\n*.log\n\n# IDE files\n# IntelliJ\n.idea/\n*.iml\n*.iws\nout/\n\n# Eclipse\n.project\n.classpath\n.settings/\nbin/\n\n# VS Code\n.vscode/\n\n# macOS\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Thumbnails\n._*\n\n# macOS metadata files\n.Spotlight-V100\n.Trashes\n\n# Maven Wrapper\n.mvn/\n!/.mvn/wrapper/maven-wrapper.jar\nmvnw\nmvnw.cmd\n\n# Environment files\n.env\n.env.*\n\n# Java crash logs (if any)\nhs_err_pid*\nreplay_pid*\n\n# Third party JAR files from Ghidra\nlib/*.jar\n\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/LaurieWired/GhidraMCP)](https://github.com/LaurieWired/GhidraMCP/releases)\n[![GitHub stars](https://img.shields.io/github/stars/LaurieWired/GhidraMCP)](https://github.com/LaurieWired/GhidraMCP/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/LaurieWired/GhidraMCP)](https://github.com/LaurieWired/GhidraMCP/network/members)\n[![GitHub contributors](https://img.shields.io/github/contributors/LaurieWired/GhidraMCP)](https://github.com/LaurieWired/GhidraMCP/graphs/contributors)\n[![Follow @lauriewired](https://img.shields.io/twitter/follow/lauriewired?style=social)](https://twitter.com/lauriewired)\n\n![ghidra_MCP_logo](https://github.com/user-attachments/assets/4986d702-be3f-4697-acce-aea55cd79ad3)\n\n\n# ghidraMCP\nghidraMCP is an Model Context Protocol server for allowing LLMs to autonomously reverse engineer applications. It exposes numerous tools from core Ghidra functionality to MCP clients.\n\nhttps://github.com/user-attachments/assets/36080514-f227-44bd-af84-78e29ee1d7f9\n\n\n# Features\nMCP Server + Ghidra Plugin\n\n- Decompile and analyze binaries in Ghidra\n- Automatically rename methods and data\n- List methods, classes, imports, and exports\n\n# Installation\n\n## Prerequisites\n- Install [Ghidra](https://ghidra-sre.org)\n- Python3\n- MCP [SDK](https://github.com/modelcontextprotocol/python-sdk)\n\n## Ghidra\nFirst, download the latest [release](https://github.com/LaurieWired/GhidraMCP/releases) from this repository. This contains the Ghidra plugin and Python MCP client. Then, you can directly import the plugin into Ghidra.\n\n1. Run Ghidra\n2. Select `File` -> `Install Extensions`\n3. Click the `+` button\n4. Select the `GhidraMCP-1-2.zip` (or your chosen version) from the downloaded release\n5. Restart Ghidra\n6. Make sure the GhidraMCPPlugin is enabled in `File` -> `Configure` -> `Developer`\n7. *Optional*: Configure the port in Ghidra with `Edit` -> `Tool Options` -> `GhidraMCP HTTP Server`\n\nVideo Installation Guide:\n\n\nhttps://github.com/user-attachments/assets/75f0c176-6da1-48dc-ad96-c182eb4648c3\n\n\n\n## MCP Clients\n\nTheoretically, any MCP client should work with ghidraMCP.  Three examples are given below.\n\n## Example 1: Claude Desktop\nTo set up Claude Desktop as a Ghidra MCP client, go to `Claude` -> `Settings` -> `Developer` -> `Edit Config` -> `claude_desktop_config.json` and add the following:\n\n```json\n{\n  \"mcpServers\": {\n    \"ghidra\": {\n      \"command\": \"python\",\n      \"args\": [\n        \"/ABSOLUTE_PATH_TO/bridge_mcp_ghidra.py\",\n        \"--ghidra-server\",\n        \"http://127.0.0.1:8080/\"\n      ]\n    }\n  }\n}\n```\n\nAlternatively, edit this file directly:\n```\n/Users/YOUR_USER/Library/Application Support/Claude/claude_desktop_config.json\n```\n\nThe server IP and port are configurable and should be set to point to the target Ghidra instance. If not set, both will default to localhost:8080.\n\n## Example 2: Cline\nTo use GhidraMCP with [Cline](https://cline.bot), this requires manually running the MCP server as well. First run the following command:\n\n```\npython bridge_mcp_ghidra.py --transport sse --mcp-host 127.0.0.1 --mcp-port 8081 --ghidra-server http://127.0.0.1:8080/\n```\n\nThe only *required* argument is the transport. If all other arguments are unspecified, they will default to the above. Once the MCP server is running, open up Cline and select `MCP Servers` at the top.\n\n![Cline select](https://github.com/user-attachments/assets/88e1f336-4729-46ee-9b81-53271e9c0ce0)\n\nThen select `Remote Servers` and add the following, ensuring that the url matches the MCP host and port:\n\n1. Server Name: GhidraMCP\n2. Server URL: `http://127.0.0.1:8081/sse`\n\n## Example 3: 5ire\nAnother MCP client that supports multiple models on the backend is [5ire](https://github.com/nanbingxyz/5ire). To set up GhidraMCP, open 5ire and go to `Tools` -> `New` and set the following configurations:\n\n1. Tool Key: ghidra\n2. Name: GhidraMCP\n3. Command: `python /ABSOLUTE_PATH_TO/bridge_mcp_ghidra.py`\n\n# Building from Source\n1. Copy the following files from your Ghidra directory to this project's `lib/` directory:\n- `Ghidra/Features/Base/lib/Base.jar`\n- `Ghidra/Features/Decompiler/lib/Decompiler.jar`\n- `Ghidra/Framework/Docking/lib/Docking.jar`\n- `Ghidra/Framework/Generic/lib/Generic.jar`\n- `Ghidra/Framework/Project/lib/Project.jar`\n- `Ghidra/Framework/SoftwareModeling/lib/SoftwareModeling.jar`\n- `Ghidra/Framework/Utility/lib/Utility.jar`\n- `Ghidra/Framework/Gui/lib/Gui.jar`\n2. Build with Maven by running:\n\n`mvn clean package assembly:single`\n\nThe generated zip file includes the built Ghidra plugin and its resources. These files are required for Ghidra to recognize the new extension.\n\n- lib/GhidraMCP.jar\n- extensions.properties\n- Module.manifest\n"
  },
  {
    "path": "bridge_mcp_ghidra.py",
    "content": "# /// script\n# requires-python = \">=3.10\"\n# dependencies = [\n#     \"requests>=2,<3\",\n#     \"mcp>=1.2.0,<2\",\n# ]\n# ///\n\nimport sys\nimport requests\nimport argparse\nimport logging\nfrom urllib.parse import urljoin\n\nfrom mcp.server.fastmcp import FastMCP\n\nDEFAULT_GHIDRA_SERVER = \"http://127.0.0.1:8080/\"\n\nlogger = logging.getLogger(__name__)\n\nmcp = FastMCP(\"ghidra-mcp\")\n\n# Initialize ghidra_server_url with default value\nghidra_server_url = DEFAULT_GHIDRA_SERVER\n\ndef safe_get(endpoint: str, params: dict = None) -> list:\n    \"\"\"\n    Perform a GET request with optional query parameters.\n    \"\"\"\n    if params is None:\n        params = {}\n\n    url = urljoin(ghidra_server_url, endpoint)\n\n    try:\n        response = requests.get(url, params=params, timeout=5)\n        response.encoding = 'utf-8'\n        if response.ok:\n            return response.text.splitlines()\n        else:\n            return [f\"Error {response.status_code}: {response.text.strip()}\"]\n    except Exception as e:\n        return [f\"Request failed: {str(e)}\"]\n\ndef safe_post(endpoint: str, data: dict | str) -> str:\n    try:\n        url = urljoin(ghidra_server_url, endpoint)\n        if isinstance(data, dict):\n            response = requests.post(url, data=data, timeout=5)\n        else:\n            response = requests.post(url, data=data.encode(\"utf-8\"), timeout=5)\n        response.encoding = 'utf-8'\n        if response.ok:\n            return response.text.strip()\n        else:\n            return f\"Error {response.status_code}: {response.text.strip()}\"\n    except Exception as e:\n        return f\"Request failed: {str(e)}\"\n\n@mcp.tool()\ndef list_methods(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List all function names in the program with pagination.\n    \"\"\"\n    return safe_get(\"methods\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef list_classes(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List all namespace/class names in the program with pagination.\n    \"\"\"\n    return safe_get(\"classes\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef decompile_function(name: str) -> str:\n    \"\"\"\n    Decompile a specific function by name and return the decompiled C code.\n    \"\"\"\n    return safe_post(\"decompile\", name)\n\n@mcp.tool()\ndef rename_function(old_name: str, new_name: str) -> str:\n    \"\"\"\n    Rename a function by its current name to a new user-defined name.\n    \"\"\"\n    return safe_post(\"renameFunction\", {\"oldName\": old_name, \"newName\": new_name})\n\n@mcp.tool()\ndef rename_data(address: str, new_name: str) -> str:\n    \"\"\"\n    Rename a data label at the specified address.\n    \"\"\"\n    return safe_post(\"renameData\", {\"address\": address, \"newName\": new_name})\n\n@mcp.tool()\ndef list_segments(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List all memory segments in the program with pagination.\n    \"\"\"\n    return safe_get(\"segments\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef list_imports(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List imported symbols in the program with pagination.\n    \"\"\"\n    return safe_get(\"imports\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef list_exports(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List exported functions/symbols with pagination.\n    \"\"\"\n    return safe_get(\"exports\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef list_namespaces(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List all non-global namespaces in the program with pagination.\n    \"\"\"\n    return safe_get(\"namespaces\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef list_data_items(offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    List defined data labels and their values with pagination.\n    \"\"\"\n    return safe_get(\"data\", {\"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef search_functions_by_name(query: str, offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    Search for functions whose name contains the given substring.\n    \"\"\"\n    if not query:\n        return [\"Error: query string is required\"]\n    return safe_get(\"searchFunctions\", {\"query\": query, \"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef rename_variable(function_name: str, old_name: str, new_name: str) -> str:\n    \"\"\"\n    Rename a local variable within a function.\n    \"\"\"\n    return safe_post(\"renameVariable\", {\n        \"functionName\": function_name,\n        \"oldName\": old_name,\n        \"newName\": new_name\n    })\n\n@mcp.tool()\ndef get_function_by_address(address: str) -> str:\n    \"\"\"\n    Get a function by its address.\n    \"\"\"\n    return \"\\n\".join(safe_get(\"get_function_by_address\", {\"address\": address}))\n\n@mcp.tool()\ndef get_current_address() -> str:\n    \"\"\"\n    Get the address currently selected by the user.\n    \"\"\"\n    return \"\\n\".join(safe_get(\"get_current_address\"))\n\n@mcp.tool()\ndef get_current_function() -> str:\n    \"\"\"\n    Get the function currently selected by the user.\n    \"\"\"\n    return \"\\n\".join(safe_get(\"get_current_function\"))\n\n@mcp.tool()\ndef list_functions() -> list:\n    \"\"\"\n    List all functions in the database.\n    \"\"\"\n    return safe_get(\"list_functions\")\n\n@mcp.tool()\ndef decompile_function_by_address(address: str) -> str:\n    \"\"\"\n    Decompile a function at the given address.\n    \"\"\"\n    return \"\\n\".join(safe_get(\"decompile_function\", {\"address\": address}))\n\n@mcp.tool()\ndef disassemble_function(address: str) -> list:\n    \"\"\"\n    Get assembly code (address: instruction; comment) for a function.\n    \"\"\"\n    return safe_get(\"disassemble_function\", {\"address\": address})\n\n@mcp.tool()\ndef set_decompiler_comment(address: str, comment: str) -> str:\n    \"\"\"\n    Set a comment for a given address in the function pseudocode.\n    \"\"\"\n    return safe_post(\"set_decompiler_comment\", {\"address\": address, \"comment\": comment})\n\n@mcp.tool()\ndef set_disassembly_comment(address: str, comment: str) -> str:\n    \"\"\"\n    Set a comment for a given address in the function disassembly.\n    \"\"\"\n    return safe_post(\"set_disassembly_comment\", {\"address\": address, \"comment\": comment})\n\n@mcp.tool()\ndef rename_function_by_address(function_address: str, new_name: str) -> str:\n    \"\"\"\n    Rename a function by its address.\n    \"\"\"\n    return safe_post(\"rename_function_by_address\", {\"function_address\": function_address, \"new_name\": new_name})\n\n@mcp.tool()\ndef set_function_prototype(function_address: str, prototype: str) -> str:\n    \"\"\"\n    Set a function's prototype.\n    \"\"\"\n    return safe_post(\"set_function_prototype\", {\"function_address\": function_address, \"prototype\": prototype})\n\n@mcp.tool()\ndef set_local_variable_type(function_address: str, variable_name: str, new_type: str) -> str:\n    \"\"\"\n    Set a local variable's type.\n    \"\"\"\n    return safe_post(\"set_local_variable_type\", {\"function_address\": function_address, \"variable_name\": variable_name, \"new_type\": new_type})\n\n@mcp.tool()\ndef get_xrefs_to(address: str, offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    Get all references to the specified address (xref to).\n    \n    Args:\n        address: Target address in hex format (e.g. \"0x1400010a0\")\n        offset: Pagination offset (default: 0)\n        limit: Maximum number of references to return (default: 100)\n        \n    Returns:\n        List of references to the specified address\n    \"\"\"\n    return safe_get(\"xrefs_to\", {\"address\": address, \"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef get_xrefs_from(address: str, offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    Get all references from the specified address (xref from).\n    \n    Args:\n        address: Source address in hex format (e.g. \"0x1400010a0\")\n        offset: Pagination offset (default: 0)\n        limit: Maximum number of references to return (default: 100)\n        \n    Returns:\n        List of references from the specified address\n    \"\"\"\n    return safe_get(\"xrefs_from\", {\"address\": address, \"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef get_function_xrefs(name: str, offset: int = 0, limit: int = 100) -> list:\n    \"\"\"\n    Get all references to the specified function by name.\n    \n    Args:\n        name: Function name to search for\n        offset: Pagination offset (default: 0)\n        limit: Maximum number of references to return (default: 100)\n        \n    Returns:\n        List of references to the specified function\n    \"\"\"\n    return safe_get(\"function_xrefs\", {\"name\": name, \"offset\": offset, \"limit\": limit})\n\n@mcp.tool()\ndef list_strings(offset: int = 0, limit: int = 2000, filter: str = None) -> list:\n    \"\"\"\n    List all defined strings in the program with their addresses.\n    \n    Args:\n        offset: Pagination offset (default: 0)\n        limit: Maximum number of strings to return (default: 2000)\n        filter: Optional filter to match within string content\n        \n    Returns:\n        List of strings with their addresses\n    \"\"\"\n    params = {\"offset\": offset, \"limit\": limit}\n    if filter:\n        params[\"filter\"] = filter\n    return safe_get(\"strings\", params)\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"MCP server for Ghidra\")\n    parser.add_argument(\"--ghidra-server\", type=str, default=DEFAULT_GHIDRA_SERVER,\n                        help=f\"Ghidra server URL, default: {DEFAULT_GHIDRA_SERVER}\")\n    parser.add_argument(\"--mcp-host\", type=str, default=\"127.0.0.1\",\n                        help=\"Host to run MCP server on (only used for sse), default: 127.0.0.1\")\n    parser.add_argument(\"--mcp-port\", type=int,\n                        help=\"Port to run MCP server on (only used for sse), default: 8081\")\n    parser.add_argument(\"--transport\", type=str, default=\"stdio\", choices=[\"stdio\", \"sse\"],\n                        help=\"Transport protocol for MCP, default: stdio\")\n    args = parser.parse_args()\n    \n    # Use the global variable to ensure it's properly updated\n    global ghidra_server_url\n    if args.ghidra_server:\n        ghidra_server_url = args.ghidra_server\n    \n    if args.transport == \"sse\":\n        try:\n            # Set up logging\n            log_level = logging.INFO\n            logging.basicConfig(level=log_level)\n            logging.getLogger().setLevel(log_level)\n\n            # Configure MCP settings\n            mcp.settings.log_level = \"INFO\"\n            if args.mcp_host:\n                mcp.settings.host = args.mcp_host\n            else:\n                mcp.settings.host = \"127.0.0.1\"\n\n            if args.mcp_port:\n                mcp.settings.port = args.mcp_port\n            else:\n                mcp.settings.port = 8081\n\n            logger.info(f\"Connecting to Ghidra server at {ghidra_server_url}\")\n            logger.info(f\"Starting MCP server on http://{mcp.settings.host}:{mcp.settings.port}/sse\")\n            logger.info(f\"Using transport: {args.transport}\")\n\n            mcp.run(transport=\"sse\")\n        except KeyboardInterrupt:\n            logger.info(\"Server stopped by user\")\n    else:\n        mcp.run()\n        \nif __name__ == \"__main__\":\n    main()\n\n"
  },
  {
    "path": "lib/.gitignore",
    "content": "*\n!.gitignore"
  },
  {
    "path": "pom.xml",
    "content": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n\n  <modelVersion>4.0.0</modelVersion>\n  <groupId>com.lauriewired</groupId>\n  <artifactId>GhidraMCP</artifactId>\n  <packaging>jar</packaging>\n  <version>1.0-SNAPSHOT</version>\n  <name>GhidraMCP</name>\n  <url>http://maven.apache.org</url>\n\n  <dependencies>\n    <!-- Ghidra JARs as system-scoped dependencies -->\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Generic</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Generic.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>SoftwareModeling</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/SoftwareModeling.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Project</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Project.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Docking</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Docking.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Decompiler</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Decompiler.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Utility</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Utility.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Base</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Base.jar</systemPath>\n    </dependency>\n    <dependency>\n      <groupId>ghidra</groupId>\n      <artifactId>Gui</artifactId>\n      <version>11.3.2</version>\n      <scope>system</scope>\n      <systemPath>${project.basedir}/lib/Gui.jar</systemPath>\n    </dependency>\n\n    <!-- JUnit (test only) -->\n    <dependency>\n      <groupId>junit</groupId>\n      <artifactId>junit</artifactId>\n      <version>3.8.1</version>\n      <scope>test</scope>\n    </dependency>\n  </dependencies>\n\n  <build>\n    <plugins>\n      <!-- Use custom MANIFEST.MF -->\n      <plugin>\n        <artifactId>maven-jar-plugin</artifactId>\n        <version>3.2.2</version>\n        <configuration>\n          <archive>\n            <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>\n          </archive>\n          <!-- Set a fixed name for the JAR without version -->\n          <finalName>GhidraMCP</finalName>\n          <!-- Exclude the App class -->\n          <excludes>\n            <exclude>**/App.class</exclude>\n          </excludes>\n          <!-- Make sure output directory is target for consistency -->\n          <outputDirectory>${project.build.directory}</outputDirectory>\n        </configuration>\n      </plugin>\n      \n      <!-- The Assembly Plugin for creating the Ghidra extension ZIP -->\n      <plugin>\n        <groupId>org.apache.maven.plugins</groupId>\n        <artifactId>maven-assembly-plugin</artifactId>\n        <version>3.3.0</version>\n        <configuration>\n          <!-- Using the custom assembly descriptor -->\n          <descriptors>\n            <descriptor>src/assembly/ghidra-extension.xml</descriptor>\n          </descriptors>\n          \n          <!-- The name of the final zip -->\n          <finalName>GhidraMCP-${project.version}</finalName>\n          \n          <!-- Don't append the assembly ID -->\n          <appendAssemblyId>false</appendAssemblyId>\n        </configuration>\n        \n        <executions>\n          <execution>\n            <id>make-assembly</id>\n            <phase>package</phase>\n            <goals>\n              <goal>single</goal>\n            </goals>\n          </execution>\n        </executions>\n      </plugin>\n      \n      <!-- Copy dependencies to target/lib for the assembly -->\n      <plugin>\n        <groupId>org.apache.maven.plugins</groupId>\n        <artifactId>maven-dependency-plugin</artifactId>\n        <version>3.1.2</version>\n        <executions>\n          <execution>\n            <id>copy-dependencies</id>\n            <phase>prepare-package</phase>\n            <goals>\n              <goal>copy-dependencies</goal>\n            </goals>\n            <configuration>\n              <outputDirectory>${project.build.directory}/lib</outputDirectory>\n              <includeScope>runtime</includeScope>\n            </configuration>\n          </execution>\n        </executions>\n      </plugin>\n    </plugins>\n  </build>\n</project>\n"
  },
  {
    "path": "requirements.txt",
    "content": "mcp==1.5.0\nrequests==2.32.3\n"
  },
  {
    "path": "src/assembly/ghidra-extension.xml",
    "content": "<assembly\n    xmlns=\"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3\"\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xsi:schemaLocation=\"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 \n        http://maven.apache.org/xsd/assembly-1.1.3.xsd\">\n    \n    <!-- Just a name for reference -->\n    <id>ghidra-extension</id>\n    \n    <!-- We want a .zip file -->\n    <formats>\n        <format>zip</format>\n    </formats>\n    \n    <!-- Don't put everything in an extra top-level directory named after the assembly ID -->\n    <includeBaseDirectory>false</includeBaseDirectory>\n    \n    <fileSets>\n        <!-- 1) Copy extension.properties and Module.manifest into the top level \n               of a folder named GhidraMCP/ (the actual extension folder). -->\n        <fileSet>\n            <directory>src/main/resources</directory>\n            <includes>\n                <include>extension.properties</include>\n                <include>Module.manifest</include>\n            </includes>\n            <outputDirectory>GhidraMCP</outputDirectory>\n        </fileSet>\n        \n        <!-- 2) Copy your built plugin JAR into GhidraMCP/lib -->\n        <fileSet>\n            <directory>${project.build.directory}</directory>\n            <includes>\n                <!-- Use the finalized JAR name from the maven-jar-plugin -->\n                <include>GhidraMCP.jar</include>\n            </includes>\n            <outputDirectory>GhidraMCP/lib</outputDirectory>\n        </fileSet>\n    </fileSets>\n</assembly>\n"
  },
  {
    "path": "src/main/java/com/lauriewired/GhidraMCPPlugin.java",
    "content": "package com.lauriewired;\n\nimport ghidra.framework.plugintool.Plugin;\nimport ghidra.framework.plugintool.PluginTool;\nimport ghidra.program.model.address.Address;\nimport ghidra.program.model.address.GlobalNamespace;\nimport ghidra.program.model.listing.*;\nimport ghidra.program.model.mem.MemoryBlock;\nimport ghidra.program.model.symbol.*;\nimport ghidra.program.model.symbol.ReferenceManager;\nimport ghidra.program.model.symbol.Reference;\nimport ghidra.program.model.symbol.ReferenceIterator;\nimport ghidra.program.model.symbol.RefType;\nimport ghidra.program.model.pcode.HighFunction;\nimport ghidra.program.model.pcode.HighSymbol;\nimport ghidra.program.model.pcode.LocalSymbolMap;\nimport ghidra.program.model.pcode.HighFunctionDBUtil;\nimport ghidra.program.model.pcode.HighFunctionDBUtil.ReturnCommitOption;\nimport ghidra.app.decompiler.DecompInterface;\nimport ghidra.app.decompiler.DecompileResults;\nimport ghidra.app.plugin.PluginCategoryNames;\nimport ghidra.app.services.CodeViewerService;\nimport ghidra.app.services.ProgramManager;\nimport ghidra.app.util.PseudoDisassembler;\nimport ghidra.app.cmd.function.SetVariableNameCmd;\nimport ghidra.program.model.symbol.SourceType;\nimport ghidra.program.model.listing.LocalVariableImpl;\nimport ghidra.program.model.listing.ParameterImpl;\nimport ghidra.util.exception.DuplicateNameException;\nimport ghidra.util.exception.InvalidInputException;\nimport ghidra.framework.plugintool.PluginInfo;\nimport ghidra.framework.plugintool.util.PluginStatus;\nimport ghidra.program.util.ProgramLocation;\nimport ghidra.util.Msg;\nimport ghidra.util.task.ConsoleTaskMonitor;\nimport ghidra.util.task.TaskMonitor;\nimport ghidra.program.model.pcode.HighVariable;\nimport ghidra.program.model.pcode.Varnode;\nimport ghidra.program.model.data.DataType;\nimport ghidra.program.model.data.DataTypeManager;\nimport ghidra.program.model.data.PointerDataType;\nimport ghidra.program.model.data.Undefined1DataType;\nimport ghidra.program.model.listing.Variable;\nimport ghidra.app.decompiler.component.DecompilerUtils;\nimport ghidra.app.decompiler.ClangToken;\nimport ghidra.framework.options.Options;\n\nimport com.sun.net.httpserver.HttpExchange;\nimport com.sun.net.httpserver.HttpServer;\n\nimport javax.swing.SwingUtilities;\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.lang.reflect.InvocationTargetException;\nimport java.net.InetSocketAddress;\nimport java.net.URLDecoder;\nimport java.nio.charset.StandardCharsets;\nimport java.util.*;\nimport java.util.concurrent.atomic.AtomicBoolean;\n\n@PluginInfo(\n    status = PluginStatus.RELEASED,\n    packageName = ghidra.app.DeveloperPluginPackage.NAME,\n    category = PluginCategoryNames.ANALYSIS,\n    shortDescription = \"HTTP server plugin\",\n    description = \"Starts an embedded HTTP server to expose program data. Port configurable via Tool Options.\"\n)\npublic class GhidraMCPPlugin extends Plugin {\n\n    private HttpServer server;\n    private static final String OPTION_CATEGORY_NAME = \"GhidraMCP HTTP Server\";\n    private static final String PORT_OPTION_NAME = \"Server Port\";\n    private static final int DEFAULT_PORT = 8080;\n\n    public GhidraMCPPlugin(PluginTool tool) {\n        super(tool);\n        Msg.info(this, \"GhidraMCPPlugin loading...\");\n\n        // Register the configuration option\n        Options options = tool.getOptions(OPTION_CATEGORY_NAME);\n        options.registerOption(PORT_OPTION_NAME, DEFAULT_PORT,\n            null, // No help location for now\n            \"The network port number the embedded HTTP server will listen on. \" +\n            \"Requires Ghidra restart or plugin reload to take effect after changing.\");\n\n        try {\n            startServer();\n        }\n        catch (IOException e) {\n            Msg.error(this, \"Failed to start HTTP server\", e);\n        }\n        Msg.info(this, \"GhidraMCPPlugin loaded!\");\n    }\n\n    private void startServer() throws IOException {\n        // Read the configured port\n        Options options = tool.getOptions(OPTION_CATEGORY_NAME);\n        int port = options.getInt(PORT_OPTION_NAME, DEFAULT_PORT);\n\n        // Stop existing server if running (e.g., if plugin is reloaded)\n        if (server != null) {\n            Msg.info(this, \"Stopping existing HTTP server before starting new one.\");\n            server.stop(0);\n            server = null;\n        }\n\n        server = HttpServer.create(new InetSocketAddress(port), 0);\n\n        // Each listing endpoint uses offset & limit from query params:\n        server.createContext(\"/methods\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, getAllFunctionNames(offset, limit));\n        });\n\n        server.createContext(\"/classes\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, getAllClassNames(offset, limit));\n        });\n\n        server.createContext(\"/decompile\", exchange -> {\n            String name = new String(exchange.getRequestBody().readAllBytes(), StandardCharsets.UTF_8);\n            sendResponse(exchange, decompileFunctionByName(name));\n        });\n\n        server.createContext(\"/renameFunction\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String response = renameFunction(params.get(\"oldName\"), params.get(\"newName\"))\n                    ? \"Renamed successfully\" : \"Rename failed\";\n            sendResponse(exchange, response);\n        });\n\n        server.createContext(\"/renameData\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            renameDataAtAddress(params.get(\"address\"), params.get(\"newName\"));\n            sendResponse(exchange, \"Rename data attempted\");\n        });\n\n        server.createContext(\"/renameVariable\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String functionName = params.get(\"functionName\");\n            String oldName = params.get(\"oldName\");\n            String newName = params.get(\"newName\");\n            String result = renameVariableInFunction(functionName, oldName, newName);\n            sendResponse(exchange, result);\n        });\n\n        server.createContext(\"/segments\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, listSegments(offset, limit));\n        });\n\n        server.createContext(\"/imports\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, listImports(offset, limit));\n        });\n\n        server.createContext(\"/exports\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, listExports(offset, limit));\n        });\n\n        server.createContext(\"/namespaces\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, listNamespaces(offset, limit));\n        });\n\n        server.createContext(\"/data\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit  = parseIntOrDefault(qparams.get(\"limit\"),  100);\n            sendResponse(exchange, listDefinedData(offset, limit));\n        });\n\n        server.createContext(\"/searchFunctions\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String searchTerm = qparams.get(\"query\");\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit = parseIntOrDefault(qparams.get(\"limit\"), 100);\n            sendResponse(exchange, searchFunctionsByName(searchTerm, offset, limit));\n        });\n\n        // New API endpoints based on requirements\n        \n        server.createContext(\"/get_function_by_address\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String address = qparams.get(\"address\");\n            sendResponse(exchange, getFunctionByAddress(address));\n        });\n\n        server.createContext(\"/get_current_address\", exchange -> {\n            sendResponse(exchange, getCurrentAddress());\n        });\n\n        server.createContext(\"/get_current_function\", exchange -> {\n            sendResponse(exchange, getCurrentFunction());\n        });\n\n        server.createContext(\"/list_functions\", exchange -> {\n            sendResponse(exchange, listFunctions());\n        });\n\n        server.createContext(\"/decompile_function\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String address = qparams.get(\"address\");\n            sendResponse(exchange, decompileFunctionByAddress(address));\n        });\n\n        server.createContext(\"/disassemble_function\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String address = qparams.get(\"address\");\n            sendResponse(exchange, disassembleFunction(address));\n        });\n\n        server.createContext(\"/set_decompiler_comment\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String address = params.get(\"address\");\n            String comment = params.get(\"comment\");\n            boolean success = setDecompilerComment(address, comment);\n            sendResponse(exchange, success ? \"Comment set successfully\" : \"Failed to set comment\");\n        });\n\n        server.createContext(\"/set_disassembly_comment\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String address = params.get(\"address\");\n            String comment = params.get(\"comment\");\n            boolean success = setDisassemblyComment(address, comment);\n            sendResponse(exchange, success ? \"Comment set successfully\" : \"Failed to set comment\");\n        });\n\n        server.createContext(\"/rename_function_by_address\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String functionAddress = params.get(\"function_address\");\n            String newName = params.get(\"new_name\");\n            boolean success = renameFunctionByAddress(functionAddress, newName);\n            sendResponse(exchange, success ? \"Function renamed successfully\" : \"Failed to rename function\");\n        });\n\n        server.createContext(\"/set_function_prototype\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String functionAddress = params.get(\"function_address\");\n            String prototype = params.get(\"prototype\");\n\n            // Call the set prototype function and get detailed result\n            PrototypeResult result = setFunctionPrototype(functionAddress, prototype);\n\n            if (result.isSuccess()) {\n                // Even with successful operations, include any warning messages for debugging\n                String successMsg = \"Function prototype set successfully\";\n                if (!result.getErrorMessage().isEmpty()) {\n                    successMsg += \"\\n\\nWarnings/Debug Info:\\n\" + result.getErrorMessage();\n                }\n                sendResponse(exchange, successMsg);\n            } else {\n                // Return the detailed error message to the client\n                sendResponse(exchange, \"Failed to set function prototype: \" + result.getErrorMessage());\n            }\n        });\n\n        server.createContext(\"/set_local_variable_type\", exchange -> {\n            Map<String, String> params = parsePostParams(exchange);\n            String functionAddress = params.get(\"function_address\");\n            String variableName = params.get(\"variable_name\");\n            String newType = params.get(\"new_type\");\n\n            // Capture detailed information about setting the type\n            StringBuilder responseMsg = new StringBuilder();\n            responseMsg.append(\"Setting variable type: \").append(variableName)\n                      .append(\" to \").append(newType)\n                      .append(\" in function at \").append(functionAddress).append(\"\\n\\n\");\n\n            // Attempt to find the data type in various categories\n            Program program = getCurrentProgram();\n            if (program != null) {\n                DataTypeManager dtm = program.getDataTypeManager();\n                DataType directType = findDataTypeByNameInAllCategories(dtm, newType);\n                if (directType != null) {\n                    responseMsg.append(\"Found type: \").append(directType.getPathName()).append(\"\\n\");\n                } else if (newType.startsWith(\"P\") && newType.length() > 1) {\n                    String baseTypeName = newType.substring(1);\n                    DataType baseType = findDataTypeByNameInAllCategories(dtm, baseTypeName);\n                    if (baseType != null) {\n                        responseMsg.append(\"Found base type for pointer: \").append(baseType.getPathName()).append(\"\\n\");\n                    } else {\n                        responseMsg.append(\"Base type not found for pointer: \").append(baseTypeName).append(\"\\n\");\n                    }\n                } else {\n                    responseMsg.append(\"Type not found directly: \").append(newType).append(\"\\n\");\n                }\n            }\n\n            // Try to set the type\n            boolean success = setLocalVariableType(functionAddress, variableName, newType);\n\n            String successMsg = success ? \"Variable type set successfully\" : \"Failed to set variable type\";\n            responseMsg.append(\"\\nResult: \").append(successMsg);\n\n            sendResponse(exchange, responseMsg.toString());\n        });\n\n        server.createContext(\"/xrefs_to\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String address = qparams.get(\"address\");\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit = parseIntOrDefault(qparams.get(\"limit\"), 100);\n            sendResponse(exchange, getXrefsTo(address, offset, limit));\n        });\n\n        server.createContext(\"/xrefs_from\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String address = qparams.get(\"address\");\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit = parseIntOrDefault(qparams.get(\"limit\"), 100);\n            sendResponse(exchange, getXrefsFrom(address, offset, limit));\n        });\n\n        server.createContext(\"/function_xrefs\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            String name = qparams.get(\"name\");\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit = parseIntOrDefault(qparams.get(\"limit\"), 100);\n            sendResponse(exchange, getFunctionXrefs(name, offset, limit));\n        });\n\n        server.createContext(\"/strings\", exchange -> {\n            Map<String, String> qparams = parseQueryParams(exchange);\n            int offset = parseIntOrDefault(qparams.get(\"offset\"), 0);\n            int limit = parseIntOrDefault(qparams.get(\"limit\"), 100);\n            String filter = qparams.get(\"filter\");\n            sendResponse(exchange, listDefinedStrings(offset, limit, filter));\n        });\n\n        server.setExecutor(null);\n        new Thread(() -> {\n            try {\n                server.start();\n                Msg.info(this, \"GhidraMCP HTTP server started on port \" + port);\n            } catch (Exception e) {\n                Msg.error(this, \"Failed to start HTTP server on port \" + port + \". Port might be in use.\", e);\n                server = null; // Ensure server isn't considered running\n            }\n        }, \"GhidraMCP-HTTP-Server\").start();\n    }\n\n    // ----------------------------------------------------------------------------------\n    // Pagination-aware listing methods\n    // ----------------------------------------------------------------------------------\n\n    private String getAllFunctionNames(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        List<String> names = new ArrayList<>();\n        for (Function f : program.getFunctionManager().getFunctions(true)) {\n            names.add(f.getName());\n        }\n        return paginateList(names, offset, limit);\n    }\n\n    private String getAllClassNames(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        Set<String> classNames = new HashSet<>();\n        for (Symbol symbol : program.getSymbolTable().getAllSymbols(true)) {\n            Namespace ns = symbol.getParentNamespace();\n            if (ns != null && !ns.isGlobal()) {\n                classNames.add(ns.getName());\n            }\n        }\n        // Convert set to list for pagination\n        List<String> sorted = new ArrayList<>(classNames);\n        Collections.sort(sorted);\n        return paginateList(sorted, offset, limit);\n    }\n\n    private String listSegments(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        List<String> lines = new ArrayList<>();\n        for (MemoryBlock block : program.getMemory().getBlocks()) {\n            lines.add(String.format(\"%s: %s - %s\", block.getName(), block.getStart(), block.getEnd()));\n        }\n        return paginateList(lines, offset, limit);\n    }\n\n    private String listImports(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        List<String> lines = new ArrayList<>();\n        for (Symbol symbol : program.getSymbolTable().getExternalSymbols()) {\n            lines.add(symbol.getName() + \" -> \" + symbol.getAddress());\n        }\n        return paginateList(lines, offset, limit);\n    }\n\n    private String listExports(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        SymbolTable table = program.getSymbolTable();\n        SymbolIterator it = table.getAllSymbols(true);\n\n        List<String> lines = new ArrayList<>();\n        while (it.hasNext()) {\n            Symbol s = it.next();\n            // On older Ghidra, \"export\" is recognized via isExternalEntryPoint()\n            if (s.isExternalEntryPoint()) {\n                lines.add(s.getName() + \" -> \" + s.getAddress());\n            }\n        }\n        return paginateList(lines, offset, limit);\n    }\n\n    private String listNamespaces(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        Set<String> namespaces = new HashSet<>();\n        for (Symbol symbol : program.getSymbolTable().getAllSymbols(true)) {\n            Namespace ns = symbol.getParentNamespace();\n            if (ns != null && !(ns instanceof GlobalNamespace)) {\n                namespaces.add(ns.getName());\n            }\n        }\n        List<String> sorted = new ArrayList<>(namespaces);\n        Collections.sort(sorted);\n        return paginateList(sorted, offset, limit);\n    }\n\n    private String listDefinedData(int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        List<String> lines = new ArrayList<>();\n        for (MemoryBlock block : program.getMemory().getBlocks()) {\n            DataIterator it = program.getListing().getDefinedData(block.getStart(), true);\n            while (it.hasNext()) {\n                Data data = it.next();\n                if (block.contains(data.getAddress())) {\n                    String label   = data.getLabel() != null ? data.getLabel() : \"(unnamed)\";\n                    String valRepr = data.getDefaultValueRepresentation();\n                    lines.add(String.format(\"%s: %s = %s\",\n                        data.getAddress(),\n                        escapeNonAscii(label),\n                        escapeNonAscii(valRepr)\n                    ));\n                }\n            }\n        }\n        return paginateList(lines, offset, limit);\n    }\n\n    private String searchFunctionsByName(String searchTerm, int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (searchTerm == null || searchTerm.isEmpty()) return \"Search term is required\";\n    \n        List<String> matches = new ArrayList<>();\n        for (Function func : program.getFunctionManager().getFunctions(true)) {\n            String name = func.getName();\n            // simple substring match\n            if (name.toLowerCase().contains(searchTerm.toLowerCase())) {\n                matches.add(String.format(\"%s @ %s\", name, func.getEntryPoint()));\n            }\n        }\n    \n        Collections.sort(matches);\n    \n        if (matches.isEmpty()) {\n            return \"No functions matching '\" + searchTerm + \"'\";\n        }\n        return paginateList(matches, offset, limit);\n    }    \n\n    // ----------------------------------------------------------------------------------\n    // Logic for rename, decompile, etc.\n    // ----------------------------------------------------------------------------------\n\n    private String decompileFunctionByName(String name) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        DecompInterface decomp = new DecompInterface();\n        decomp.openProgram(program);\n        for (Function func : program.getFunctionManager().getFunctions(true)) {\n            if (func.getName().equals(name)) {\n                DecompileResults result =\n                    decomp.decompileFunction(func, 30, new ConsoleTaskMonitor());\n                if (result != null && result.decompileCompleted()) {\n                    return result.getDecompiledFunction().getC();\n                } else {\n                    return \"Decompilation failed\";\n                }\n            }\n        }\n        return \"Function not found\";\n    }\n\n    private boolean renameFunction(String oldName, String newName) {\n        Program program = getCurrentProgram();\n        if (program == null) return false;\n\n        AtomicBoolean successFlag = new AtomicBoolean(false);\n        try {\n            SwingUtilities.invokeAndWait(() -> {\n                int tx = program.startTransaction(\"Rename function via HTTP\");\n                try {\n                    for (Function func : program.getFunctionManager().getFunctions(true)) {\n                        if (func.getName().equals(oldName)) {\n                            func.setName(newName, SourceType.USER_DEFINED);\n                            successFlag.set(true);\n                            break;\n                        }\n                    }\n                }\n                catch (Exception e) {\n                    Msg.error(this, \"Error renaming function\", e);\n                }\n                finally {\n                    successFlag.set(program.endTransaction(tx, successFlag.get()));\n                }\n            });\n        }\n        catch (InterruptedException | InvocationTargetException e) {\n            Msg.error(this, \"Failed to execute rename on Swing thread\", e);\n        }\n        return successFlag.get();\n    }\n\n    private void renameDataAtAddress(String addressStr, String newName) {\n        Program program = getCurrentProgram();\n        if (program == null) return;\n\n        try {\n            SwingUtilities.invokeAndWait(() -> {\n                int tx = program.startTransaction(\"Rename data\");\n                try {\n                    Address addr = program.getAddressFactory().getAddress(addressStr);\n                    Listing listing = program.getListing();\n                    Data data = listing.getDefinedDataAt(addr);\n                    if (data != null) {\n                        SymbolTable symTable = program.getSymbolTable();\n                        Symbol symbol = symTable.getPrimarySymbol(addr);\n                        if (symbol != null) {\n                            symbol.setName(newName, SourceType.USER_DEFINED);\n                        } else {\n                            symTable.createLabel(addr, newName, SourceType.USER_DEFINED);\n                        }\n                    }\n                }\n                catch (Exception e) {\n                    Msg.error(this, \"Rename data error\", e);\n                }\n                finally {\n                    program.endTransaction(tx, true);\n                }\n            });\n        }\n        catch (InterruptedException | InvocationTargetException e) {\n            Msg.error(this, \"Failed to execute rename data on Swing thread\", e);\n        }\n    }\n\n    private String renameVariableInFunction(String functionName, String oldVarName, String newVarName) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        DecompInterface decomp = new DecompInterface();\n        decomp.openProgram(program);\n\n        Function func = null;\n        for (Function f : program.getFunctionManager().getFunctions(true)) {\n            if (f.getName().equals(functionName)) {\n                func = f;\n                break;\n            }\n        }\n\n        if (func == null) {\n            return \"Function not found\";\n        }\n\n        DecompileResults result = decomp.decompileFunction(func, 30, new ConsoleTaskMonitor());\n        if (result == null || !result.decompileCompleted()) {\n            return \"Decompilation failed\";\n        }\n\n        HighFunction highFunction = result.getHighFunction();\n        if (highFunction == null) {\n            return \"Decompilation failed (no high function)\";\n        }\n\n        LocalSymbolMap localSymbolMap = highFunction.getLocalSymbolMap();\n        if (localSymbolMap == null) {\n            return \"Decompilation failed (no local symbol map)\";\n        }\n\n        HighSymbol highSymbol = null;\n        Iterator<HighSymbol> symbols = localSymbolMap.getSymbols();\n        while (symbols.hasNext()) {\n            HighSymbol symbol = symbols.next();\n            String symbolName = symbol.getName();\n            \n            if (symbolName.equals(oldVarName)) {\n                highSymbol = symbol;\n            }\n            if (symbolName.equals(newVarName)) {\n                return \"Error: A variable with name '\" + newVarName + \"' already exists in this function\";\n            }\n        }\n\n        if (highSymbol == null) {\n            return \"Variable not found\";\n        }\n\n        boolean commitRequired = checkFullCommit(highSymbol, highFunction);\n\n        final HighSymbol finalHighSymbol = highSymbol;\n        final Function finalFunction = func;\n        AtomicBoolean successFlag = new AtomicBoolean(false);\n\n        try {\n            SwingUtilities.invokeAndWait(() -> {           \n                int tx = program.startTransaction(\"Rename variable\");\n                try {\n                    if (commitRequired) {\n                        HighFunctionDBUtil.commitParamsToDatabase(highFunction, false,\n                            ReturnCommitOption.NO_COMMIT, finalFunction.getSignatureSource());\n                    }\n                    HighFunctionDBUtil.updateDBVariable(\n                        finalHighSymbol,\n                        newVarName,\n                        null,\n                        SourceType.USER_DEFINED\n                    );\n                    successFlag.set(true);\n                }\n                catch (Exception e) {\n                    Msg.error(this, \"Failed to rename variable\", e);\n                }\n                finally {\n                    successFlag.set(program.endTransaction(tx, true));\n                }\n            });\n        } catch (InterruptedException | InvocationTargetException e) {\n            String errorMsg = \"Failed to execute rename on Swing thread: \" + e.getMessage();\n            Msg.error(this, errorMsg, e);\n            return errorMsg;\n        }\n        return successFlag.get() ? \"Variable renamed\" : \"Failed to rename variable\";\n    }\n\n    /**\n     * Copied from AbstractDecompilerAction.checkFullCommit, it's protected.\n\t * Compare the given HighFunction's idea of the prototype with the Function's idea.\n\t * Return true if there is a difference. If a specific symbol is being changed,\n\t * it can be passed in to check whether or not the prototype is being affected.\n\t * @param highSymbol (if not null) is the symbol being modified\n\t * @param hfunction is the given HighFunction\n\t * @return true if there is a difference (and a full commit is required)\n\t */\n\tprotected static boolean checkFullCommit(HighSymbol highSymbol, HighFunction hfunction) {\n\t\tif (highSymbol != null && !highSymbol.isParameter()) {\n\t\t\treturn false;\n\t\t}\n\t\tFunction function = hfunction.getFunction();\n\t\tParameter[] parameters = function.getParameters();\n\t\tLocalSymbolMap localSymbolMap = hfunction.getLocalSymbolMap();\n\t\tint numParams = localSymbolMap.getNumParams();\n\t\tif (numParams != parameters.length) {\n\t\t\treturn true;\n\t\t}\n\n\t\tfor (int i = 0; i < numParams; i++) {\n\t\t\tHighSymbol param = localSymbolMap.getParamSymbol(i);\n\t\t\tif (param.getCategoryIndex() != i) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tVariableStorage storage = param.getStorage();\n\t\t\t// Don't compare using the equals method so that DynamicVariableStorage can match\n\t\t\tif (0 != storage.compareTo(parameters[i].getVariableStorage())) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n    // ----------------------------------------------------------------------------------\n    // New methods to implement the new functionalities\n    // ----------------------------------------------------------------------------------\n\n    /**\n     * Get function by address\n     */\n    private String getFunctionByAddress(String addressStr) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (addressStr == null || addressStr.isEmpty()) return \"Address is required\";\n\n        try {\n            Address addr = program.getAddressFactory().getAddress(addressStr);\n            Function func = program.getFunctionManager().getFunctionAt(addr);\n\n            if (func == null) return \"No function found at address \" + addressStr;\n\n            return String.format(\"Function: %s at %s\\nSignature: %s\\nEntry: %s\\nBody: %s - %s\",\n                func.getName(),\n                func.getEntryPoint(),\n                func.getSignature(),\n                func.getEntryPoint(),\n                func.getBody().getMinAddress(),\n                func.getBody().getMaxAddress());\n        } catch (Exception e) {\n            return \"Error getting function: \" + e.getMessage();\n        }\n    }\n\n    /**\n     * Get current address selected in Ghidra GUI\n     */\n    private String getCurrentAddress() {\n        CodeViewerService service = tool.getService(CodeViewerService.class);\n        if (service == null) return \"Code viewer service not available\";\n\n        ProgramLocation location = service.getCurrentLocation();\n        return (location != null) ? location.getAddress().toString() : \"No current location\";\n    }\n\n    /**\n     * Get current function selected in Ghidra GUI\n     */\n    private String getCurrentFunction() {\n        CodeViewerService service = tool.getService(CodeViewerService.class);\n        if (service == null) return \"Code viewer service not available\";\n\n        ProgramLocation location = service.getCurrentLocation();\n        if (location == null) return \"No current location\";\n\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        Function func = program.getFunctionManager().getFunctionContaining(location.getAddress());\n        if (func == null) return \"No function at current location: \" + location.getAddress();\n\n        return String.format(\"Function: %s at %s\\nSignature: %s\",\n            func.getName(),\n            func.getEntryPoint(),\n            func.getSignature());\n    }\n\n    /**\n     * List all functions in the database\n     */\n    private String listFunctions() {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        StringBuilder result = new StringBuilder();\n        for (Function func : program.getFunctionManager().getFunctions(true)) {\n            result.append(String.format(\"%s at %s\\n\", \n                func.getName(), \n                func.getEntryPoint()));\n        }\n\n        return result.toString();\n    }\n\n    /**\n     * Gets a function at the given address or containing the address\n     * @return the function or null if not found\n     */\n    private Function getFunctionForAddress(Program program, Address addr) {\n        Function func = program.getFunctionManager().getFunctionAt(addr);\n        if (func == null) {\n            func = program.getFunctionManager().getFunctionContaining(addr);\n        }\n        return func;\n    }\n\n    /**\n     * Decompile a function at the given address\n     */\n    private String decompileFunctionByAddress(String addressStr) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (addressStr == null || addressStr.isEmpty()) return \"Address is required\";\n\n        try {\n            Address addr = program.getAddressFactory().getAddress(addressStr);\n            Function func = getFunctionForAddress(program, addr);\n            if (func == null) return \"No function found at or containing address \" + addressStr;\n\n            DecompInterface decomp = new DecompInterface();\n            decomp.openProgram(program);\n            DecompileResults result = decomp.decompileFunction(func, 30, new ConsoleTaskMonitor());\n\n            return (result != null && result.decompileCompleted()) \n                ? result.getDecompiledFunction().getC() \n                : \"Decompilation failed\";\n        } catch (Exception e) {\n            return \"Error decompiling function: \" + e.getMessage();\n        }\n    }\n\n    /**\n     * Get assembly code for a function\n     */\n    private String disassembleFunction(String addressStr) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (addressStr == null || addressStr.isEmpty()) return \"Address is required\";\n\n        try {\n            Address addr = program.getAddressFactory().getAddress(addressStr);\n            Function func = getFunctionForAddress(program, addr);\n            if (func == null) return \"No function found at or containing address \" + addressStr;\n\n            StringBuilder result = new StringBuilder();\n            Listing listing = program.getListing();\n            Address start = func.getEntryPoint();\n            Address end = func.getBody().getMaxAddress();\n\n            InstructionIterator instructions = listing.getInstructions(start, true);\n            while (instructions.hasNext()) {\n                Instruction instr = instructions.next();\n                if (instr.getAddress().compareTo(end) > 0) {\n                    break; // Stop if we've gone past the end of the function\n                }\n                String comment = listing.getComment(CodeUnit.EOL_COMMENT, instr.getAddress());\n                comment = (comment != null) ? \"; \" + comment : \"\";\n\n                result.append(String.format(\"%s: %s %s\\n\", \n                    instr.getAddress(), \n                    instr.toString(),\n                    comment));\n            }\n\n            return result.toString();\n        } catch (Exception e) {\n            return \"Error disassembling function: \" + e.getMessage();\n        }\n    }    \n\n    /**\n     * Set a comment using the specified comment type (PRE_COMMENT or EOL_COMMENT)\n     */\n    private boolean setCommentAtAddress(String addressStr, String comment, int commentType, String transactionName) {\n        Program program = getCurrentProgram();\n        if (program == null) return false;\n        if (addressStr == null || addressStr.isEmpty() || comment == null) return false;\n\n        AtomicBoolean success = new AtomicBoolean(false);\n\n        try {\n            SwingUtilities.invokeAndWait(() -> {\n                int tx = program.startTransaction(transactionName);\n                try {\n                    Address addr = program.getAddressFactory().getAddress(addressStr);\n                    program.getListing().setComment(addr, commentType, comment);\n                    success.set(true);\n                } catch (Exception e) {\n                    Msg.error(this, \"Error setting \" + transactionName.toLowerCase(), e);\n                } finally {\n                    success.set(program.endTransaction(tx, success.get()));\n                }\n            });\n        } catch (InterruptedException | InvocationTargetException e) {\n            Msg.error(this, \"Failed to execute \" + transactionName.toLowerCase() + \" on Swing thread\", e);\n        }\n\n        return success.get();\n    }\n\n    /**\n     * Set a comment for a given address in the function pseudocode\n     */\n    private boolean setDecompilerComment(String addressStr, String comment) {\n        return setCommentAtAddress(addressStr, comment, CodeUnit.PRE_COMMENT, \"Set decompiler comment\");\n    }\n\n    /**\n     * Set a comment for a given address in the function disassembly\n     */\n    private boolean setDisassemblyComment(String addressStr, String comment) {\n        return setCommentAtAddress(addressStr, comment, CodeUnit.EOL_COMMENT, \"Set disassembly comment\");\n    }\n\n    /**\n     * Class to hold the result of a prototype setting operation\n     */\n    private static class PrototypeResult {\n        private final boolean success;\n        private final String errorMessage;\n\n        public PrototypeResult(boolean success, String errorMessage) {\n            this.success = success;\n            this.errorMessage = errorMessage;\n        }\n\n        public boolean isSuccess() {\n            return success;\n        }\n\n        public String getErrorMessage() {\n            return errorMessage;\n        }\n    }\n\n    /**\n     * Rename a function by its address\n     */\n    private boolean renameFunctionByAddress(String functionAddrStr, String newName) {\n        Program program = getCurrentProgram();\n        if (program == null) return false;\n        if (functionAddrStr == null || functionAddrStr.isEmpty() || \n            newName == null || newName.isEmpty()) {\n            return false;\n        }\n\n        AtomicBoolean success = new AtomicBoolean(false);\n\n        try {\n            SwingUtilities.invokeAndWait(() -> {\n                performFunctionRename(program, functionAddrStr, newName, success);\n            });\n        } catch (InterruptedException | InvocationTargetException e) {\n            Msg.error(this, \"Failed to execute rename function on Swing thread\", e);\n        }\n\n        return success.get();\n    }\n\n    /**\n     * Helper method to perform the actual function rename within a transaction\n     */\n    private void performFunctionRename(Program program, String functionAddrStr, String newName, AtomicBoolean success) {\n        int tx = program.startTransaction(\"Rename function by address\");\n        try {\n            Address addr = program.getAddressFactory().getAddress(functionAddrStr);\n            Function func = getFunctionForAddress(program, addr);\n\n            if (func == null) {\n                Msg.error(this, \"Could not find function at address: \" + functionAddrStr);\n                return;\n            }\n\n            func.setName(newName, SourceType.USER_DEFINED);\n            success.set(true);\n        } catch (Exception e) {\n            Msg.error(this, \"Error renaming function by address\", e);\n        } finally {\n            program.endTransaction(tx, success.get());\n        }\n    }\n\n    /**\n     * Set a function's prototype with proper error handling using ApplyFunctionSignatureCmd\n     */\n    private PrototypeResult setFunctionPrototype(String functionAddrStr, String prototype) {\n        // Input validation\n        Program program = getCurrentProgram();\n        if (program == null) return new PrototypeResult(false, \"No program loaded\");\n        if (functionAddrStr == null || functionAddrStr.isEmpty()) {\n            return new PrototypeResult(false, \"Function address is required\");\n        }\n        if (prototype == null || prototype.isEmpty()) {\n            return new PrototypeResult(false, \"Function prototype is required\");\n        }\n\n        final StringBuilder errorMessage = new StringBuilder();\n        final AtomicBoolean success = new AtomicBoolean(false);\n\n        try {\n            SwingUtilities.invokeAndWait(() -> \n                applyFunctionPrototype(program, functionAddrStr, prototype, success, errorMessage));\n        } catch (InterruptedException | InvocationTargetException e) {\n            String msg = \"Failed to set function prototype on Swing thread: \" + e.getMessage();\n            errorMessage.append(msg);\n            Msg.error(this, msg, e);\n        }\n\n        return new PrototypeResult(success.get(), errorMessage.toString());\n    }\n\n    /**\n     * Helper method that applies the function prototype within a transaction\n     */\n    private void applyFunctionPrototype(Program program, String functionAddrStr, String prototype, \n                                       AtomicBoolean success, StringBuilder errorMessage) {\n        try {\n            // Get the address and function\n            Address addr = program.getAddressFactory().getAddress(functionAddrStr);\n            Function func = getFunctionForAddress(program, addr);\n\n            if (func == null) {\n                String msg = \"Could not find function at address: \" + functionAddrStr;\n                errorMessage.append(msg);\n                Msg.error(this, msg);\n                return;\n            }\n\n            Msg.info(this, \"Setting prototype for function \" + func.getName() + \": \" + prototype);\n\n            // Store original prototype as a comment for reference\n            addPrototypeComment(program, func, prototype);\n\n            // Use ApplyFunctionSignatureCmd to parse and apply the signature\n            parseFunctionSignatureAndApply(program, addr, prototype, success, errorMessage);\n\n        } catch (Exception e) {\n            String msg = \"Error setting function prototype: \" + e.getMessage();\n            errorMessage.append(msg);\n            Msg.error(this, msg, e);\n        }\n    }\n\n    /**\n     * Add a comment showing the prototype being set\n     */\n    private void addPrototypeComment(Program program, Function func, String prototype) {\n        int txComment = program.startTransaction(\"Add prototype comment\");\n        try {\n            program.getListing().setComment(\n                func.getEntryPoint(), \n                CodeUnit.PLATE_COMMENT, \n                \"Setting prototype: \" + prototype\n            );\n        } finally {\n            program.endTransaction(txComment, true);\n        }\n    }\n\n    /**\n     * Parse and apply the function signature with error handling\n     */\n    private void parseFunctionSignatureAndApply(Program program, Address addr, String prototype,\n                                              AtomicBoolean success, StringBuilder errorMessage) {\n        // Use ApplyFunctionSignatureCmd to parse and apply the signature\n        int txProto = program.startTransaction(\"Set function prototype\");\n        try {\n            // Get data type manager\n            DataTypeManager dtm = program.getDataTypeManager();\n\n            // Get data type manager service\n            ghidra.app.services.DataTypeManagerService dtms = \n                tool.getService(ghidra.app.services.DataTypeManagerService.class);\n\n            // Create function signature parser\n            ghidra.app.util.parser.FunctionSignatureParser parser = \n                new ghidra.app.util.parser.FunctionSignatureParser(dtm, dtms);\n\n            // Parse the prototype into a function signature\n            ghidra.program.model.data.FunctionDefinitionDataType sig = parser.parse(null, prototype);\n\n            if (sig == null) {\n                String msg = \"Failed to parse function prototype\";\n                errorMessage.append(msg);\n                Msg.error(this, msg);\n                return;\n            }\n\n            // Create and apply the command\n            ghidra.app.cmd.function.ApplyFunctionSignatureCmd cmd = \n                new ghidra.app.cmd.function.ApplyFunctionSignatureCmd(\n                    addr, sig, SourceType.USER_DEFINED);\n\n            // Apply the command to the program\n            boolean cmdResult = cmd.applyTo(program, new ConsoleTaskMonitor());\n\n            if (cmdResult) {\n                success.set(true);\n                Msg.info(this, \"Successfully applied function signature\");\n            } else {\n                String msg = \"Command failed: \" + cmd.getStatusMsg();\n                errorMessage.append(msg);\n                Msg.error(this, msg);\n            }\n        } catch (Exception e) {\n            String msg = \"Error applying function signature: \" + e.getMessage();\n            errorMessage.append(msg);\n            Msg.error(this, msg, e);\n        } finally {\n            program.endTransaction(txProto, success.get());\n        }\n    }\n\n    /**\n     * Set a local variable's type using HighFunctionDBUtil.updateDBVariable\n     */\n    private boolean setLocalVariableType(String functionAddrStr, String variableName, String newType) {\n        // Input validation\n        Program program = getCurrentProgram();\n        if (program == null) return false;\n        if (functionAddrStr == null || functionAddrStr.isEmpty() || \n            variableName == null || variableName.isEmpty() ||\n            newType == null || newType.isEmpty()) {\n            return false;\n        }\n\n        AtomicBoolean success = new AtomicBoolean(false);\n\n        try {\n            SwingUtilities.invokeAndWait(() -> \n                applyVariableType(program, functionAddrStr, variableName, newType, success));\n        } catch (InterruptedException | InvocationTargetException e) {\n            Msg.error(this, \"Failed to execute set variable type on Swing thread\", e);\n        }\n\n        return success.get();\n    }\n\n    /**\n     * Helper method that performs the actual variable type change\n     */\n    private void applyVariableType(Program program, String functionAddrStr, \n                                  String variableName, String newType, AtomicBoolean success) {\n        try {\n            // Find the function\n            Address addr = program.getAddressFactory().getAddress(functionAddrStr);\n            Function func = getFunctionForAddress(program, addr);\n\n            if (func == null) {\n                Msg.error(this, \"Could not find function at address: \" + functionAddrStr);\n                return;\n            }\n\n            DecompileResults results = decompileFunction(func, program);\n            if (results == null || !results.decompileCompleted()) {\n                return;\n            }\n\n            ghidra.program.model.pcode.HighFunction highFunction = results.getHighFunction();\n            if (highFunction == null) {\n                Msg.error(this, \"No high function available\");\n                return;\n            }\n\n            // Find the symbol by name\n            HighSymbol symbol = findSymbolByName(highFunction, variableName);\n            if (symbol == null) {\n                Msg.error(this, \"Could not find variable '\" + variableName + \"' in decompiled function\");\n                return;\n            }\n\n            // Get high variable\n            HighVariable highVar = symbol.getHighVariable();\n            if (highVar == null) {\n                Msg.error(this, \"No HighVariable found for symbol: \" + variableName);\n                return;\n            }\n\n            Msg.info(this, \"Found high variable for: \" + variableName + \n                     \" with current type \" + highVar.getDataType().getName());\n\n            // Find the data type\n            DataTypeManager dtm = program.getDataTypeManager();\n            DataType dataType = resolveDataType(dtm, newType);\n\n            if (dataType == null) {\n                Msg.error(this, \"Could not resolve data type: \" + newType);\n                return;\n            }\n\n            Msg.info(this, \"Using data type: \" + dataType.getName() + \" for variable \" + variableName);\n\n            // Apply the type change in a transaction\n            updateVariableType(program, symbol, dataType, success);\n\n        } catch (Exception e) {\n            Msg.error(this, \"Error setting variable type: \" + e.getMessage());\n        }\n    }\n\n    /**\n     * Find a high symbol by name in the given high function\n     */\n    private HighSymbol findSymbolByName(ghidra.program.model.pcode.HighFunction highFunction, String variableName) {\n        Iterator<HighSymbol> symbols = highFunction.getLocalSymbolMap().getSymbols();\n        while (symbols.hasNext()) {\n            HighSymbol s = symbols.next();\n            if (s.getName().equals(variableName)) {\n                return s;\n            }\n        }\n        return null;\n    }\n\n    /**\n     * Decompile a function and return the results\n     */\n    private DecompileResults decompileFunction(Function func, Program program) {\n        // Set up decompiler for accessing the decompiled function\n        DecompInterface decomp = new DecompInterface();\n        decomp.openProgram(program);\n        decomp.setSimplificationStyle(\"decompile\"); // Full decompilation\n\n        // Decompile the function\n        DecompileResults results = decomp.decompileFunction(func, 60, new ConsoleTaskMonitor());\n\n        if (!results.decompileCompleted()) {\n            Msg.error(this, \"Could not decompile function: \" + results.getErrorMessage());\n            return null;\n        }\n\n        return results;\n    }\n\n    /**\n     * Apply the type update in a transaction\n     */\n    private void updateVariableType(Program program, HighSymbol symbol, DataType dataType, AtomicBoolean success) {\n        int tx = program.startTransaction(\"Set variable type\");\n        try {\n            // Use HighFunctionDBUtil to update the variable with the new type\n            HighFunctionDBUtil.updateDBVariable(\n                symbol,                // The high symbol to modify\n                symbol.getName(),      // Keep original name\n                dataType,              // The new data type\n                SourceType.USER_DEFINED // Mark as user-defined\n            );\n\n            success.set(true);\n            Msg.info(this, \"Successfully set variable type using HighFunctionDBUtil\");\n        } catch (Exception e) {\n            Msg.error(this, \"Error setting variable type: \" + e.getMessage());\n        } finally {\n            program.endTransaction(tx, success.get());\n        }\n    }\n\n    /**\n     * Get all references to a specific address (xref to)\n     */\n    private String getXrefsTo(String addressStr, int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (addressStr == null || addressStr.isEmpty()) return \"Address is required\";\n\n        try {\n            Address addr = program.getAddressFactory().getAddress(addressStr);\n            ReferenceManager refManager = program.getReferenceManager();\n            \n            ReferenceIterator refIter = refManager.getReferencesTo(addr);\n            \n            List<String> refs = new ArrayList<>();\n            while (refIter.hasNext()) {\n                Reference ref = refIter.next();\n                Address fromAddr = ref.getFromAddress();\n                RefType refType = ref.getReferenceType();\n                \n                Function fromFunc = program.getFunctionManager().getFunctionContaining(fromAddr);\n                String funcInfo = (fromFunc != null) ? \" in \" + fromFunc.getName() : \"\";\n                \n                refs.add(String.format(\"From %s%s [%s]\", fromAddr, funcInfo, refType.getName()));\n            }\n            \n            return paginateList(refs, offset, limit);\n        } catch (Exception e) {\n            return \"Error getting references to address: \" + e.getMessage();\n        }\n    }\n\n    /**\n     * Get all references from a specific address (xref from)\n     */\n    private String getXrefsFrom(String addressStr, int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (addressStr == null || addressStr.isEmpty()) return \"Address is required\";\n\n        try {\n            Address addr = program.getAddressFactory().getAddress(addressStr);\n            ReferenceManager refManager = program.getReferenceManager();\n            \n            Reference[] references = refManager.getReferencesFrom(addr);\n            \n            List<String> refs = new ArrayList<>();\n            for (Reference ref : references) {\n                Address toAddr = ref.getToAddress();\n                RefType refType = ref.getReferenceType();\n                \n                String targetInfo = \"\";\n                Function toFunc = program.getFunctionManager().getFunctionAt(toAddr);\n                if (toFunc != null) {\n                    targetInfo = \" to function \" + toFunc.getName();\n                } else {\n                    Data data = program.getListing().getDataAt(toAddr);\n                    if (data != null) {\n                        targetInfo = \" to data \" + (data.getLabel() != null ? data.getLabel() : data.getPathName());\n                    }\n                }\n                \n                refs.add(String.format(\"To %s%s [%s]\", toAddr, targetInfo, refType.getName()));\n            }\n            \n            return paginateList(refs, offset, limit);\n        } catch (Exception e) {\n            return \"Error getting references from address: \" + e.getMessage();\n        }\n    }\n\n    /**\n     * Get all references to a specific function by name\n     */\n    private String getFunctionXrefs(String functionName, int offset, int limit) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n        if (functionName == null || functionName.isEmpty()) return \"Function name is required\";\n\n        try {\n            List<String> refs = new ArrayList<>();\n            FunctionManager funcManager = program.getFunctionManager();\n            for (Function function : funcManager.getFunctions(true)) {\n                if (function.getName().equals(functionName)) {\n                    Address entryPoint = function.getEntryPoint();\n                    ReferenceIterator refIter = program.getReferenceManager().getReferencesTo(entryPoint);\n                    \n                    while (refIter.hasNext()) {\n                        Reference ref = refIter.next();\n                        Address fromAddr = ref.getFromAddress();\n                        RefType refType = ref.getReferenceType();\n                        \n                        Function fromFunc = funcManager.getFunctionContaining(fromAddr);\n                        String funcInfo = (fromFunc != null) ? \" in \" + fromFunc.getName() : \"\";\n                        \n                        refs.add(String.format(\"From %s%s [%s]\", fromAddr, funcInfo, refType.getName()));\n                    }\n                }\n            }\n            \n            if (refs.isEmpty()) {\n                return \"No references found to function: \" + functionName;\n            }\n            \n            return paginateList(refs, offset, limit);\n        } catch (Exception e) {\n            return \"Error getting function references: \" + e.getMessage();\n        }\n    }\n\n/**\n * List all defined strings in the program with their addresses\n */\n    private String listDefinedStrings(int offset, int limit, String filter) {\n        Program program = getCurrentProgram();\n        if (program == null) return \"No program loaded\";\n\n        List<String> lines = new ArrayList<>();\n        DataIterator dataIt = program.getListing().getDefinedData(true);\n        \n        while (dataIt.hasNext()) {\n            Data data = dataIt.next();\n            \n            if (data != null && isStringData(data)) {\n                String value = data.getValue() != null ? data.getValue().toString() : \"\";\n                \n                if (filter == null || value.toLowerCase().contains(filter.toLowerCase())) {\n                    String escapedValue = escapeString(value);\n                    lines.add(String.format(\"%s: \\\"%s\\\"\", data.getAddress(), escapedValue));\n                }\n            }\n        }\n        \n        return paginateList(lines, offset, limit);\n    }\n\n    /**\n     * Check if the given data is a string type\n     */\n    private boolean isStringData(Data data) {\n        if (data == null) return false;\n        \n        DataType dt = data.getDataType();\n        String typeName = dt.getName().toLowerCase();\n        return typeName.contains(\"string\") || typeName.contains(\"char\") || typeName.equals(\"unicode\");\n    }\n\n    /**\n     * Escape special characters in a string for display\n     */\n    private String escapeString(String input) {\n        if (input == null) return \"\";\n        \n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i < input.length(); i++) {\n            char c = input.charAt(i);\n            if (c >= 32 && c < 127) {\n                sb.append(c);\n            } else if (c == '\\n') {\n                sb.append(\"\\\\n\");\n            } else if (c == '\\r') {\n                sb.append(\"\\\\r\");\n            } else if (c == '\\t') {\n                sb.append(\"\\\\t\");\n            } else {\n                sb.append(String.format(\"\\\\x%02x\", (int)c & 0xFF));\n            }\n        }\n        return sb.toString();\n    }\n\n    /**\n     * Resolves a data type by name, handling common types and pointer types\n     * @param dtm The data type manager\n     * @param typeName The type name to resolve\n     * @return The resolved DataType, or null if not found\n     */\n    private DataType resolveDataType(DataTypeManager dtm, String typeName) {\n        // First try to find exact match in all categories\n        DataType dataType = findDataTypeByNameInAllCategories(dtm, typeName);\n        if (dataType != null) {\n            Msg.info(this, \"Found exact data type match: \" + dataType.getPathName());\n            return dataType;\n        }\n\n        // Check for Windows-style pointer types (PXXX)\n        if (typeName.startsWith(\"P\") && typeName.length() > 1) {\n            String baseTypeName = typeName.substring(1);\n\n            // Special case for PVOID\n            if (baseTypeName.equals(\"VOID\")) {\n                return new PointerDataType(dtm.getDataType(\"/void\"));\n            }\n\n            // Try to find the base type\n            DataType baseType = findDataTypeByNameInAllCategories(dtm, baseTypeName);\n            if (baseType != null) {\n                return new PointerDataType(baseType);\n            }\n\n            Msg.warn(this, \"Base type not found for \" + typeName + \", defaulting to void*\");\n            return new PointerDataType(dtm.getDataType(\"/void\"));\n        }\n\n        // Handle common built-in types\n        switch (typeName.toLowerCase()) {\n            case \"int\":\n            case \"long\":\n                return dtm.getDataType(\"/int\");\n            case \"uint\":\n            case \"unsigned int\":\n            case \"unsigned long\":\n            case \"dword\":\n                return dtm.getDataType(\"/uint\");\n            case \"short\":\n                return dtm.getDataType(\"/short\");\n            case \"ushort\":\n            case \"unsigned short\":\n            case \"word\":\n                return dtm.getDataType(\"/ushort\");\n            case \"char\":\n            case \"byte\":\n                return dtm.getDataType(\"/char\");\n            case \"uchar\":\n            case \"unsigned char\":\n                return dtm.getDataType(\"/uchar\");\n            case \"longlong\":\n            case \"__int64\":\n                return dtm.getDataType(\"/longlong\");\n            case \"ulonglong\":\n            case \"unsigned __int64\":\n                return dtm.getDataType(\"/ulonglong\");\n            case \"bool\":\n            case \"boolean\":\n                return dtm.getDataType(\"/bool\");\n            case \"void\":\n                return dtm.getDataType(\"/void\");\n            default:\n                // Try as a direct path\n                DataType directType = dtm.getDataType(\"/\" + typeName);\n                if (directType != null) {\n                    return directType;\n                }\n\n                // Fallback to int if we couldn't find it\n                Msg.warn(this, \"Unknown type: \" + typeName + \", defaulting to int\");\n                return dtm.getDataType(\"/int\");\n        }\n    }\n    \n    /**\n     * Find a data type by name in all categories/folders of the data type manager\n     * This searches through all categories rather than just the root\n     */\n    private DataType findDataTypeByNameInAllCategories(DataTypeManager dtm, String typeName) {\n        // Try exact match first\n        DataType result = searchByNameInAllCategories(dtm, typeName);\n        if (result != null) {\n            return result;\n        }\n\n        // Try lowercase\n        return searchByNameInAllCategories(dtm, typeName.toLowerCase());\n    }\n\n    /**\n     * Helper method to search for a data type by name in all categories\n     */\n    private DataType searchByNameInAllCategories(DataTypeManager dtm, String name) {\n        // Get all data types from the manager\n        Iterator<DataType> allTypes = dtm.getAllDataTypes();\n        while (allTypes.hasNext()) {\n            DataType dt = allTypes.next();\n            // Check if the name matches exactly (case-sensitive) \n            if (dt.getName().equals(name)) {\n                return dt;\n            }\n            // For case-insensitive, we want an exact match except for case\n            if (dt.getName().equalsIgnoreCase(name)) {\n                return dt;\n            }\n        }\n        return null;\n    }\n\n    // ----------------------------------------------------------------------------------\n    // Utility: parse query params, parse post params, pagination, etc.\n    // ----------------------------------------------------------------------------------\n\n    /**\n     * Parse query parameters from the URL, e.g. ?offset=10&limit=100\n     */\n    private Map<String, String> parseQueryParams(HttpExchange exchange) {\n        Map<String, String> result = new HashMap<>();\n        String query = exchange.getRequestURI().getQuery(); // e.g. offset=10&limit=100\n        if (query != null) {\n            String[] pairs = query.split(\"&\");\n            for (String p : pairs) {\n                String[] kv = p.split(\"=\");\n                if (kv.length == 2) {\n                    // URL decode parameter values\n                    try {\n                        String key = URLDecoder.decode(kv[0], StandardCharsets.UTF_8);\n                        String value = URLDecoder.decode(kv[1], StandardCharsets.UTF_8);\n                        result.put(key, value);\n                    } catch (Exception e) {\n                        Msg.error(this, \"Error decoding URL parameter\", e);\n                    }\n                }\n            }\n        }\n        return result;\n    }\n\n    /**\n     * Parse post body form params, e.g. oldName=foo&newName=bar\n     */\n    private Map<String, String> parsePostParams(HttpExchange exchange) throws IOException {\n        byte[] body = exchange.getRequestBody().readAllBytes();\n        String bodyStr = new String(body, StandardCharsets.UTF_8);\n        Map<String, String> params = new HashMap<>();\n        for (String pair : bodyStr.split(\"&\")) {\n            String[] kv = pair.split(\"=\");\n            if (kv.length == 2) {\n                // URL decode parameter values\n                try {\n                    String key = URLDecoder.decode(kv[0], StandardCharsets.UTF_8);\n                    String value = URLDecoder.decode(kv[1], StandardCharsets.UTF_8);\n                    params.put(key, value);\n                } catch (Exception e) {\n                    Msg.error(this, \"Error decoding URL parameter\", e);\n                }\n            }\n        }\n        return params;\n    }\n\n    /**\n     * Convert a list of strings into one big newline-delimited string, applying offset & limit.\n     */\n    private String paginateList(List<String> items, int offset, int limit) {\n        int start = Math.max(0, offset);\n        int end   = Math.min(items.size(), offset + limit);\n\n        if (start >= items.size()) {\n            return \"\"; // no items in range\n        }\n        List<String> sub = items.subList(start, end);\n        return String.join(\"\\n\", sub);\n    }\n\n    /**\n     * Parse an integer from a string, or return defaultValue if null/invalid.\n     */\n    private int parseIntOrDefault(String val, int defaultValue) {\n        if (val == null) return defaultValue;\n        try {\n            return Integer.parseInt(val);\n        }\n        catch (NumberFormatException e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Escape non-ASCII chars to avoid potential decode issues.\n     */\n    private String escapeNonAscii(String input) {\n        if (input == null) return \"\";\n        StringBuilder sb = new StringBuilder();\n        for (char c : input.toCharArray()) {\n            if (c >= 32 && c < 127) {\n                sb.append(c);\n            }\n            else {\n                sb.append(\"\\\\x\");\n                sb.append(Integer.toHexString(c & 0xFF));\n            }\n        }\n        return sb.toString();\n    }\n\n    public Program getCurrentProgram() {\n        ProgramManager pm = tool.getService(ProgramManager.class);\n        return pm != null ? pm.getCurrentProgram() : null;\n    }\n\n    private void sendResponse(HttpExchange exchange, String response) throws IOException {\n        byte[] bytes = response.getBytes(StandardCharsets.UTF_8);\n        exchange.getResponseHeaders().set(\"Content-Type\", \"text/plain; charset=utf-8\");\n        exchange.sendResponseHeaders(200, bytes.length);\n        try (OutputStream os = exchange.getResponseBody()) {\n            os.write(bytes);\n        }\n    }\n\n    @Override\n    public void dispose() {\n        if (server != null) {\n            Msg.info(this, \"Stopping GhidraMCP HTTP server...\");\n            server.stop(1); // Stop with a small delay (e.g., 1 second) for connections to finish\n            server = null; // Nullify the reference\n            Msg.info(this, \"GhidraMCP HTTP server stopped.\");\n        }\n        super.dispose();\n    }\n}\n"
  },
  {
    "path": "src/main/resources/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nPlugin-Class: com.lauriewired.GhidraMCP\nPlugin-Name: GhidraMCP\nPlugin-Version: 1.0\nPlugin-Author: LaurieWired\nPlugin-Description: A custom plugin by LaurieWired\n"
  },
  {
    "path": "src/main/resources/Module.manifest",
    "content": "GHIDRA_MODULE_NAME=GhidraMCP\nGHIDRA_MODULE_DESC=An HTTP server plugin for Ghidra\n"
  },
  {
    "path": "src/main/resources/extension.properties",
    "content": "name=GhidraMCP\ndescription=A plugin that runs an embedded HTTP server to expose program data.\nauthor=LaurieWired\ncreatedOn=2025-03-22\nversion=11.3.2\nghidraVersion=11.3.2"
  },
  {
    "path": "src/test/java/com/lauriewired/AppTest.java",
    "content": "package com.lauriewired;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\n\n/**\n * Unit test for simple App.\n */\npublic class AppTest \n    extends TestCase\n{\n    /**\n     * Create the test case\n     *\n     * @param testName name of the test case\n     */\n    public AppTest( String testName )\n    {\n        super( testName );\n    }\n\n    /**\n     * @return the suite of tests being tested\n     */\n    public static Test suite()\n    {\n        return new TestSuite( AppTest.class );\n    }\n\n    /**\n     * Rigourous Test :-)\n     */\n    public void testApp()\n    {\n        assertTrue( true );\n    }\n}\n"
  }
]