This test exercises mcp tool context.

-- flags --
-mcp
-ignore_extra_diags

-- go.mod --
module example.com

-- a/main.go --
// File doc for main.go part 1.
package main

// File doc for main.go part 2.
import(
    "example.com/a/comment"
)

// File doc for main.go part 3.

// doc comment for func foo.
func foo() {//@mcptool("context", `{}`, "foo", output=withComment)
    comment.Foo("", 0)
}

-- a/a.go --
// File doc for a.go.
package main

// doc comment for func a.
func a () {}

// doc comment for type b.
type b struct {}

// doc comment for const c.
const c = ""

// doc comment for var d.
var d int

-- a/comment/doc.go --
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
Package doc for package comment.
*/
package comment

-- a/comment/comment.go --
// File doc for comment.go part 1.
package comment

// File doc for comment.go part 2.
import (
    // comment for package renaming.
    myfmt "fmt"
)

// File doc for comment.go part 3.

// doc comment for comment.Foo
func Foo(foo string, _ int) {
    myfmt.Printf("%s", foo)
}

// Random comment floating around.

-- @withComment --
Code blocks are delimited by --->...<--- markers.

Current package "example.com/a" (package main) declares the following symbols:

main.go (current file):
--->
// File doc for main.go part 1.
package main

// File doc for main.go part 2.
import(
    "example.com/a/comment"
)

// File doc for main.go part 3.

// doc comment for func foo.
func foo()

<---

a.go:
--->
// File doc for a.go.
package main

// doc comment for func a.
func a ()

// doc comment for type b.
type b struct {}
// doc comment for const c.
const c = ""
// doc comment for var d.
var d int
<---

Current file "main.go" contains this import declaration:
--->
import(
    "example.com/a/comment"
)
<---

The imported packages declare the following symbols:

"example.com/a/comment" (package comment)
comment.go:
--->
// File doc for comment.go part 1.
package comment

// File doc for comment.go part 2.
import (
    // comment for package renaming.
    myfmt "fmt"
)

// File doc for comment.go part 3.

// doc comment for comment.Foo
func Foo(foo string, _ int)

<---

doc.go:
--->
/*
Package doc for package comment.
*/
package comment

<---

-- b/main.go --
package main

import(
    "example.com/b/function"
)

func testFunction() {//@mcptool("context", `{}`, "test", output=withFunction)
    function.Foo(0, "")
}

-- b/function/function.go --
package function

func Foo(int, string) {}

func foo(string, int) {}

type unexported struct {}

func (*unexported) unexported(int) {}

func (*unexported) Exported(int) {}

type Exported struct{}

func (*Exported) unexported(int) {}

func (*Exported) Exported(int) {}

-- @withFunction --
Code blocks are delimited by --->...<--- markers.

Current package "example.com/b" (package main) declares the following symbols:

main.go (current file):
--->
package main

import(
    "example.com/b/function"
)

func testFunction()

<---

Current file "main.go" contains this import declaration:
--->
import(
    "example.com/b/function"
)
<---

The imported packages declare the following symbols:

"example.com/b/function" (package function)
function.go:
--->
package function

func Foo(int, string)

type Exported struct{}

func (*Exported) Exported(int)

<---

-- c/main.go --
package main

import(
    "example.com/c/types"
)

var x types.Exported //@mcptool("context", `{}`, "x", output=withType)

-- c/types/types.go --
package types

// Doc for exported.
type Exported struct {
    // Doc for exported.
    Exported string
    // Doc for unexported.
    unexported string
}

// Doc for types.
type (
    // Doc for Foo first line.
    // Doc for Foo second line.
    Foo struct {
        foo string
    }

    // Doc for foo.
    foo struct {}

    // Doc for Bar.
    Bar struct {
        bar string
    }

    // Doc for bar.
    bar struct {}
)

-- @withType --
Code blocks are delimited by --->...<--- markers.

Current package "example.com/c" (package main) declares the following symbols:

main.go (current file):
--->
package main

import(
    "example.com/c/types"
)

var x types.Exported
<---

Current file "main.go" contains this import declaration:
--->
import(
    "example.com/c/types"
)
<---

The imported packages declare the following symbols:

"example.com/c/types" (package types)
types.go:
--->
package types

// Doc for exported.
type Exported struct {
    // Doc for exported.
    Exported string
    // Doc for unexported.
    unexported string
}

// Doc for types.
type (
    // Doc for Foo first line.
    // Doc for Foo second line.
    Foo struct {
        foo string
    }
    // Doc for Bar.
    Bar struct {
        bar string
    }
)

<---

-- d/main.go --
package main

import(
    "example.com/d/values"
)

var y values.ConstFoo //@mcptool("context", `{}`, "y", output=withValue)

-- d/values/consts.go --
package values

const (
    // doc for ConstFoo
    ConstFoo = "Foo" // comment for ConstFoo
    // doc for constFoo
    constFoo = "foo" // comment for constFoo
    // doc for ConstBar
    ConstBar = "Bar" // comment for ConstBar
    // doc for constBar
    constBar = "bar" // comment for constBar
)

// doc for ConstExported
const ConstExported = "Exported" // comment for ConstExported

// doc for constUnexported
var constUnexported = "unexported" // comment for constUnexported

-- d/values/vars.go --
package values

var (
    // doc for VarFoo
    VarFoo = "Foo" // comment for VarFoo
    // doc for varFoo
    varFoo = "foo" // comment for varFoo
    // doc for VarBar
    VarBar = "Bar" // comment for VarBar
    // doc for varBar
    varBar = "bar" // comment for varBar
)

// doc for VarExported
var VarExported = "Exported" // comment for VarExported

// doc for varUnexported
var varUnexported = "unexported" // comment for varUnexported

-- @withValue --
Code blocks are delimited by --->...<--- markers.

Current package "example.com/d" (package main) declares the following symbols:

main.go (current file):
--->
package main

import(
    "example.com/d/values"
)

var y values.ConstFoo
<---

Current file "main.go" contains this import declaration:
--->
import(
    "example.com/d/values"
)
<---

The imported packages declare the following symbols:

"example.com/d/values" (package values)
consts.go:
--->
package values

const (
    // doc for ConstFoo
    ConstFoo = "Foo" // comment for ConstFoo
    // doc for ConstBar
    ConstBar = "Bar" // comment for ConstBar
)

// doc for ConstExported
const ConstExported = "Exported" // comment for ConstExported

<---

vars.go:
--->
package values

var (
    // doc for VarFoo
    VarFoo = "Foo" // comment for VarFoo
    // doc for VarBar
    VarBar = "Bar" // comment for VarBar
)

// doc for VarExported
var VarExported = "Exported" // comment for VarExported

<---

-- e/main.go --
package main

func main() {} //@mcptool("context", `{}`, "main", output=samePackage)

-- e/foo.go --
package main

var (
    foo string
    Foo string
)

-- e/bar.go --
package main

const (
    bar = ""
    Bar = ""
)

-- e/baz.go --
package main

func baz(int) string {
    return ""
}

func Baz(string) int {
    return 0
}

-- @samePackage --
Code blocks are delimited by --->...<--- markers.

Current package "example.com/e" (package main) declares the following symbols:

main.go (current file):
--->
package main

func main()

<---

bar.go:
--->
package main

const (
    bar = ""
    Bar = ""
)
<---

baz.go:
--->
package main

func baz(int) string

func Baz(string) int

<---

foo.go:
--->
package main

var (
    foo string
    Foo string
)
<---

