Did you know ... Search Documentation:
Pack mcp -- prolog/mcp/servers/source.pl
PublicShow source

Lets a coding agent without a local checkout fetch source from this server. Every tool takes a root name (e.g. swipl or 'swipl-source'); the relative path is then resolved against the configured directory and validated to stay inside it (no .. escapes).

Tools registered:

  • source_roots list the configured roots and whether each is a git work-tree
  • source_list list files in a sub-directory of a root
  • source_read read a file (or a line range) from a root
  • source_search POSIX-ERE grep across a root's tree

Roots:

  • The swipl root is provided by default and points at home directory of the running Prolog system.
  • The 'swipl-source' gives access to the GIT checked out source tree. If SWI-Prolog is executed from the build tree, this is discovered automatically. Otherwise it must be specified on the commandline as swipl -Dcmake_source_directory=Path ...
  • Additional roots are added by writing multifile clauses for source_root/2. Note that the specification can use path aliases as accepted by absolute_file_name/3. This must expand to a directory.
    :- multifile mcp_server_source:source_root/2.
    mcp_server_source:source_root('chat80', pack(chat80)).
 source_root_path(?Name, -Path) is nondet
True when Path is to be searched for sources under the given Name.
 source_root(?Name, ?Path) is nondet[multifile]
Multifile. Lists the configured source roots.