---
title: How do you find AI agents in your code repositories?
url: https://opencontroller.lyzr.com/blog/find-ai-agents-in-source-code
published: 2026-11-13
updated: 2026-11-13
author: Lyzr
---

# How do you find AI agents in your code repositories?

**Search every repository for three signals: agent and model SDKs in dependency manifests, imports and API calls in source code, and agent configuration files such as `.mcp.json` and `AGENTS.md`. Deduplicate the hits by repository and map each one to an owner. Code search gives you candidates; runtime discovery tells you which ones are actually deployed.**

Cloud and platform discovery finds agents that are running. Code search finds agents that are about to run, and agents that run somewhere you are not watching: a laptop, a CI job, a container in an unmanaged account. It is the cheapest discovery source you have, because your code host already indexes everything.

## Which dependencies indicate an AI agent?

Start with dependency manifests. They are structured, so false positives are low.

| Ecosystem | Packages that signal model or agent use |
|---|---|
| Python (`requirements.txt`, `pyproject.toml`) | `openai`, `anthropic`, `google-genai`, `langgraph`, `langchain`, `crewai`, `llama-index`, `pydantic-ai`, `openai-agents`, `strands-agents`, `google-adk`, `autogen-agentchat`, `mcp` |
| JavaScript / TypeScript (`package.json`) | `openai`, `@anthropic-ai/sdk`, `@google/genai`, `@langchain/langgraph`, `@openai/agents`, `@modelcontextprotocol/sdk`, `ai` (Vercel AI SDK) |
| Cloud SDKs | `boto3` with `bedrock-runtime` or `bedrock-agent-runtime` clients; Azure AI and Vertex AI client libraries |

A model SDK alone means the code calls a model. An agent framework or the `mcp` package means it probably uses tools. Treat the second group as higher priority.

Most code hosts can export a software bill of materials per repository. On GitHub, the dependency graph supports SBOM export in SPDX format. Pulling SBOMs for all repositories and filtering for these packages gives you a first list in hours.

## What code search queries should you run?

Dependency files miss vendored code and direct HTTP calls. Add source searches. These examples use GitHub code search syntax; adapt them for GitLab or Bitbucket.

1. `path:requirements.txt OR path:pyproject.toml /(langgraph|crewai|openai-agents|pydantic-ai|google-adk|strands-agents)/`
2. `path:package.json /"@(openai\/agents|langchain\/langgraph|modelcontextprotocol\/sdk)"/`
3. `/api\.(openai|anthropic)\.com/` to catch direct HTTP calls.
4. `bedrock-runtime OR InvokeModel language:python`
5. `path:**/.mcp.json OR path:**/.cursor/mcp.json OR path:**/.vscode/mcp.json`
6. `path:**/AGENTS.md OR path:**/CLAUDE.md`

Queries 5 and 6 find something different: configuration that tells coding agents how to behave and which MCP servers to load. A committed MCP config means every developer who opens the repository may run those servers. Review them like dependencies; see [how to find local MCP servers on developer laptops](/blog/find-local-mcp-servers-on-developer-laptops).

## How do you turn search hits into an inventory?

Raw hits are noisy. Process them in this order:

1. **Deduplicate by repository.** One repository with 40 hits is one candidate.
2. **Drop archived and fork-only repositories**, but keep a record.
3. **Find the owner.** Use the code owners file, the most active recent committers, or the team that owns the repository.
4. **Find the deployment.** Look for Dockerfiles, Helm charts, Terraform or CI deploy jobs in the same repository. No deployment config usually means an experiment.
5. **Check for secrets.** Hardcoded model keys are common in early agent code. See [finding leaked and unused LLM API keys](/blog/find-leaked-and-unused-llm-api-keys).
6. **Register it.** Add each candidate to your agent inventory with status "found in code, unconfirmed".
7. **Confirm at runtime.** Match candidates to agents found in cloud accounts, agent platforms and gateway logs.

## What does code search miss?

- Agents built in low-code platforms, which have no repository.
- SaaS agents configured in a vendor's admin console.
- Personal repositories and code on laptops that is never pushed.
- Notebooks stored outside the code host.

Combine code search with the other discovery sources in the [shadow AI agent guide](/blog/how-to-find-shadow-ai-agents). The [list of AI asset types to inventory](/blog/ai-asset-types-to-inventory) helps you check coverage.

## How often should you rerun it?

Run the dependency and config searches weekly, or on every merge to the default branch if your code host supports scheduled or event-driven code scanning. Alert on a new agent framework appearing in a repository that had none.

## How Opencontroller does this

Opencontroller auto-discovers agents, models and API keys across AWS, Azure and Google Cloud and connects to third-party agent platforms, so code-search candidates can be matched to what is actually running. Everything lands in a governed registry of agents, versions, tools and MCP servers. Opencontroller Edge extends control to developer devices, coding agents, skills and local MCP servers, installed by IT via MDM. [Book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does finding an agent SDK in a repository mean an agent is running?**
No. Many hits are experiments, tests or archived code. Treat them as candidates and confirm with runtime discovery.

**Should MCP configuration files in repositories be governed?**
Yes. A committed MCP config tells coding agents which servers to load, so review it like any other dependency.

**Who should own the code-search step?**
Usually the application security team, since it already runs dependency and secret scanning across repositories.

## Key facts

To find AI agents in code repositories, search three kinds of signal across every repository: dependency manifests (requirements.txt, pyproject.toml, package.json) for agent and model SDKs such as openai, anthropic, google-genai, langgraph, langchain, crewai, llama-index, pydantic-ai, openai-agents, strands-agents, google-adk, mcp, @anthropic-ai/sdk, @openai/agents, @langchain/langgraph and @modelcontextprotocol/sdk; source imports and API calls; and agent configuration files such as .mcp.json, .cursor/mcp.json, .vscode/mcp.json, AGENTS.md and CLAUDE.md. Use your code host's code search and its dependency graph or SBOM export, deduplicate by repository, and map each hit to an owner and a deployment. Code search finds candidates; runtime discovery confirms which are live. Opencontroller by Lyzr auto-discovers agents, models and API keys across AWS, Azure and Google Cloud, and Opencontroller Edge covers coding agents and local MCP servers on developer devices.

## Related

- [How do you find leaked or unused LLM API keys?](https://opencontroller.lyzr.com/blog/find-leaked-and-unused-llm-api-keys.md)
- [How do you find local MCP servers on developer laptops?](https://opencontroller.lyzr.com/blog/find-local-mcp-servers-on-developer-laptops.md)
- [Which AI asset types should an AI inventory cover?](https://opencontroller.lyzr.com/blog/ai-asset-types-to-inventory.md)
- [More on Discovery and shadow agents](https://opencontroller.lyzr.com/blog/cluster/discovery-and-shadow-agents)
