帮助:使用反射发现和调用方法
2 分•作者: ddddazed•3 个月前
各位 HN 的朋友们,
我一直在进行不同的 MCP 项目,每次都需要编写 MCP 服务器作为方法/函数的包装器。
然后我意识到,在使用内存管理型语言时,我可以通过反射直接扫描应用程序内部的方法,然后直接调用。
是的,我仍然需要编写包含名称、参数和描述的 JSON 文件,但这对我来说是可以接受的,因为已经有程序可以自动完成这项工作。
现在我只是想知道,是否有人已经将这种模式应用于 MCP,以避免编写包装器并解锁潜在的功能:
* 避免更新任何代码部分,只需更新 JSON。
* 尝试解锁代码中尚未计划的功能,这样代理就有可能访问代码的任何部分。
这只是一个实验,旨在了解它能解锁多少潜力以及是否有意义。
有人尝试过这种技术方法吗?
是否有任何通用反馈,或者来自已经尝试过的人的意见?
查看原文
Hi HN,
I was working on different MCP project, every time I have to write MCP server as wrapper of methods\functions.<p>Then I realize that with memory managed languages I can use reflection to scan methods directly insiede the application and then just fire.<p>Yes, I still need to write json file with name,arguments and description but this is fine to me, there are already program to do this in automatic way.<p>Now I was just wondering if some one else has already use this kind of pattern over MCP to avoid wrapper and unlock potential things:<p>- Avoid update any part of the code, just update json.<p>- Try to unlock potential thigs that are has not been scheduled on code, with this the agent has potentially access to any part of code.<p>It's just an experiment to see how much potential it unlocks and whether it makes sense.
Has anyone ever tried this technical approach?<p>Any general feedback, or input from anyone who has already tried it?